PDA

View Full Version : [SOLVED:] Cell color



JLandrum
05-14-2015, 09:49 AM
I have this code, what I would like it to do is add a cell color when the value is "NH". Thanks for any help


Private Sub CommandButton21_Click()
Dim x, lr, c As Long
lr = Cells(Rows.Count, 3).End(xlUp).Row
Range("D11:D" & lr).ClearContents
c = 0
For x = 11 To lr
If Cells(x, 3).Value > Cells(4, 2).Value Then
Cells(x, 4).Value = "NH"
c = c + 1
End If
Next x

End Sub

Yongle
05-14-2015, 10:41 AM
Rather than use VBA, better to use standard conditional formatting

Highlight the range that you want to format then
on Home tab select conditional formatting /New Rule/Format only Cells that Contain...
then select format only cells with cell value Equal to
and type NH
then click on Format and choose your colour and click on ok

JLandrum
05-14-2015, 11:00 AM
Thank you, I ended up using it afterwards.