conditional formatting, when select a cell.

S

Saad

hi,
i want to make conditional formatting to a cell (say A2) only of i selct
B2...how to write this select command in contional formatting box?
 
B

Bernie Deitrick

Saad,

You could use the selection change event. Copy the code below, right-click the sheet tab, select
"View Code" and paste the code in the window that appears.

The code will change the fill of cell A2 to red when B2 is selected.

HTH,
Bernie
MS Excel MVP

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$2" Then
Range("A2").Interior.ColorIndex = 3
Else
Range("A2").Interior.ColorIndex = xlNone
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top