ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   conditional formatting, when select a cell. (https://www.excelbanter.com/excel-discussion-misc-queries/232489-conditional-formatting-when-select-cell.html)

Saad

conditional formatting, when select a cell.
 
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?

Bernie Deitrick

conditional formatting, when select a cell.
 
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


"Saad" wrote in message
...
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?





All times are GMT +1. The time now is 08:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com