[VBA] Conditional Formatting
The following event code will change the same row in Columns A, B and C to
red if you enter a value into Column D and will remove that color if you
delete the value in Column D. It will also allow you to make changes to
multiple cells at one time as well.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim R As Range
For Each R In Target
If R.Column = 4 Then
With R.Offset(, -3).Resize(1, 3).Interior
If Len(R.Value) 0 Then
.ColorIndex = 3
Else
.ColorIndex = 0
End If
End With
End If
Next
End Sub
To install it, right click the tab at the bottom of the worksheet you want
it to apply to, select View Code from the pop up menu that appears and then
copy/paste the above code into the code window that appears.
--
Rick (MVP - Excel)
"Eddie_SP" wrote in message
...
Hi Community !
I need help.
I do not want to use "Conditional Formatting" in Excel. I need it by VBA.
If I put any value in a cell of column "D", columns A, B and C must be
changed to red colour.
I will need it in many cases, but as I've never worked with Cond. Form. in
VBA, it will help me in many ways in the future.
I thank you in advance ! =)
|