Highlight values of column B in column D

Closed
kansara Posts 2 Registration date Thursday September 24, 2009 Status Member Last seen September 25, 2009 - Sep 25, 2009 at 01:50 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Sep 25, 2009 at 10:40 PM
Hello,
I made a sheet named Room List. In this sheet. I have 4 columns. In column D, I have numbers 1,2,3,4,5,6,7,8,9 in cells D2, D3, D4, D5, D6, D7, D8, D9, D10 respectively.
In column B, if I write any number, it should be highlighted by color in relative cell of column D.
Example: If I write number 5 in cell B2 of column B, a cell D6 should be highlighted by a different color because D6 contains number 5 which I wrote in cell B2.
Can I do that please? It will be great help to me if I will get response to this at the earliest.

1 response

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Sep 25, 2009 at 10:40 PM
right click the sheet TAB and lcick VIEWCODE. in that window copy paste this code
This is an event code.




Private Sub Worksheet_Change(ByVal Target As Range)
Dim cfind As Range
Range("d1:d9").Interior.ColorIndex = xlNone
If Target.Address <> "$B$2" Then Exit Sub
With Range("d1:d10")
Set cfind = .Cells.Find(what:=Target.Value, lookat:=xlWhole)
If Not cfind Is Nothing Then cfind.Interior.ColorIndex = 3
End With
End Sub


now type any number in B2 and see what happen in column D
0