Fill matching cell value with a yellow background color

Moonbeam111

Board Regular
Joined
Sep 24, 2018
Messages
73
Office Version
  1. 365
  2. 2010
Hi all,

I have names that stretch from T1 to W28 (1 name per cell). I also have a name in cell C3 that I pick from a drop down list that corresponds to those names in cells T1 to W28.

What I'm trying to achieve is this: When I select a name from the drop down list in cell C3. I would like the vba function to look for the name that I selected from cell C3 and match it to the same name that is somewhere within T1 to W28 and fill it with a yellow background color.

I've tried a few codes but its not working. This is all basically so I know which names have already been selected from the drop down list so I don't select them again. Any help would be greatly appreciated.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
In the events of your sheet put the following:


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address = "$C$3" Then
    Dim f As Range
    Set f = Range("T1:W28").Find(Target.Value, , xlValues, xlWhole, , , False)
    If Not f Is Nothing Then
      f.Interior.Color = vbYellow
    End If
  End If
End Sub

Note Sheet Event:
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.


----- --
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
----- --
 
Upvote 0
Solution

Forum statistics

Threads
1,223,249
Messages
6,171,031
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top