Macro Code:
Sub MyConditions()
'define the starting point of calculations
'row second
Row=2
'start the loop and continue till the cell B2 is not empty
Do While Cells(Row,2)<>""
Cells(Row,3).Value=Cells(Row,2)*0.3
Cells(Row,4).Value=Cells(Row,2)*0.1
Cells(Row,5).Value=Cells(Row,2).Value+Cells(Row,3).Value+Cells(Row,4).Value
'format the cells based on specified conditions
If Cells(Row,5).Value>=8000 Then
Cells(Row,5).Font.Bold=True
Cells(Row,5).Font.ColorIndex=3
ElseIf Cells(Row,5).Value>=7000 Then
Cells(Row,5).Font.ColorIndex=4
ElseIf Cells(Row,5).Value>=3000 Then
Cells(Row,5).Font.ColorIndex=5
End If
'go to next row i. e. 3
'now loop again and perform the actions if cell B3 is not empty
and so on...
Row=Row+1
Loop
End Sub
|