Highlight values of column B in column D

Closed
kansara Posts 2 Registration date Thursday 24 September 2009 Status Member Last seen 25 September 2009 - 25 Sep 2009 à 01:50
venkat1926 Posts 1863 Registration date Sunday 14 June 2009 Status Contributor Last seen 7 August 2021 - 25 Sep 2009 à 22:40
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 14 June 2009 Status Contributor Last seen 7 August 2021 811
25 Sep 2009 à 22:40
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