Find and select cell to match value from combobox and Turn Cell Green in Sheet1

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hi Hope you can help please, i have a Userform with a ComboBox1 and this has a list of names, when a name is selected ie 'John Smith' I want to find all the names B:B in Sheet1 with this name (John Smith) for example and turn that cell Green, please can you help me,
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi

Maybe something like:

VBA Code:
Private Sub ComboBox1_Change()
    Dim Cll As Range
    Dim sh As Worksheet, f As Range
    Set sh = Sheets("Sheet1")
    Set f = sh.Range("B1:B1000").Find(ComboBox1.Value, , xlValues, xlWhole)
    If Not f Is Nothing Then
        sh.Select
        f.Select
    Else
        MsgBox "Does not exist"
    End If
    For Each Cll In sh.Range("B1:B1000")
        If Cll.Value = f Then
            Cll.Interior.Color = vbGreen
        End If
        Next Cll
    End Sub
 
Upvote 0
HI thank you for the code i get an error on the last 'end if' it says blocked.
 
Upvote 0
How are you populating the list inside the ComboBox? What is the error number you are getting?
 
Upvote 0
HI actually i got it working now thank you

Glad to hear that and help... what was the issue giving the error? Also maybe just then mark the thread as solution so others can easily find it.
 
Upvote 0
Glad to hear that and help... what was the issue giving the error? Also maybe just then mark the thread as solution so others can easily find it.
I don’t know to be honest I restarted the document and put it in a different place and it worked. Thank you again for the support
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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