sir, I want to highlight excel cell by selecting different cell. for example:
highlight cell b2 when cell c2 is selected and highlight cell b2 when cell d2 is selected and highlight cell b2 when cell e2 is selected and like so on……
the following code is working for highlighting the left/right cell but I want to have a multiple conditions.
Private Sub Worksheet_SelectionChange(ByVal target As Range)
On Error Resume Next
‘Get address to reset highlighting
oldTarget = Range(“C2”)
‘Reset highlighting
Range(oldTarget).Interior.ColorIndex = xlNone
‘Highlight cell -1 columns to the right
target.Offset(0, -1).Interior.ColorIndex = 6
‘Store highlighted cell address for use next time
Range(“C2”) = target.Offset(0, -1).Address
End Sub
message edited by Azan
Click Here Before Posting Data or VBA Code —> How To Post Data or Code.