Professional Documents
Culture Documents
Macro Application: This Macro Works and Changes The Font To Bold Whenever The Cell Contains "1005"
Macro Application: This Macro Works and Changes The Font To Bold Whenever The Cell Contains "1005"
Sub Test1()
This Macro Works and changes the font to bold whenever the cell contains 1005
For Each MyCell In Selection
If MyCell.Value Like "1005" Then
MyCell.Font.Bold = True
End If
Next
End Sub
----------------------------------------------------------------------------------------------------------------------------------Sub TestCondition2() This Macro Works
For Each Mycell In Selection
If Mycell.Value > "5000" Then
MsgBox "Target Achieved"
Else
MsgBox "Target Not Achieved"
End If
Next
End Sub
---------------------------------------------------------------------------------------------------------------------------------Sub TestCondition1() ' It works & makes the cell Bold and also Counts the No of cells whose value is < 1005
i=0
For Each mycell In Selection
If mycell.Value < "1005" Then
mycell.Font.Bold = True
i=i+1
End If
Next
Cells(1, 21).Value = i
' It puts the value of I into cell U1
End Sub
----------------------------------------------------------------------------------------------------------------------------------Sub Test1() ' It makes the range of cell Bold, colored and also Counts the No of cells whose value is < 1019 and > 1019
For Each MyCell In Selection
If MyCell.Value > "1019" Then
MyCell.Font.Bold = True
MyCell.Interior.ColorIndex = 4
gr = gr + 1
ElseIf MyCell.Value < "1019" Then
MyCell.Interior.ColorIndex = 6
sm = sm + 1
Else
MyCell.Interior.ColorIndex = 3
End If
Next
Cells(1, 21).Value = gr
Cells(1, 21).Interior.ColorIndex = 4
Cells(1, 22).Value = "Values >1019"
Cells(2, 21).Value = sm
Cells(2, 21).Interior.ColorIndex = 6
Cells(2, 22).Value = "Values<1019"
End Sub
-------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------