tinkermary
New Member
- Joined
- Dec 12, 2008
- Messages
- 16
I need vb code for filling a cell color if another cell contains a value greater than 0.
For example: If the value in cell B14 is greater than 0 then cell b2 will be filled with Yellow color, otherwise it will not be filled.
I tried creating my own but wasn't sure about the "IF" and "THEN" info.
This seems easy but it isn't working for me. Code is below:
Private Sub CommandButton1_Click()
If Range("b18") > 0 Then
ColorIndex = 10
Pattern = xlSolid
PatternColorIndex = xlAutomatic
End If
End Sub
For example: If the value in cell B14 is greater than 0 then cell b2 will be filled with Yellow color, otherwise it will not be filled.
I tried creating my own but wasn't sure about the "IF" and "THEN" info.
This seems easy but it isn't working for me. Code is below:
Private Sub CommandButton1_Click()
If Range("b18") > 0 Then
ColorIndex = 10
Pattern = xlSolid
PatternColorIndex = xlAutomatic
End If
End Sub