Find and select cell to match value from combobox

picklefactory

Well-known Member
Joined
Jan 28, 2005
Messages
508
Office Version
  1. 365
Platform
  1. Windows
Hello folks
Stumped again.... :(
I want to find and select a cell via VBA based on a text value picked from a userform combobox. The target value will be a text value in a single column which will NOT be sorted and may contain blanks. Is that doable at all?
Thanks
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this

Change data in red for your information

Code:
Private Sub ComboBox1_Change()
  Dim sh As Worksheet, f As Range
  If ComboBox1.Value = "" Or ComboBox1.ListIndex = -1 Then Exit Sub
  Set sh = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")
  Set f = sh.Range("[COLOR=#ff0000]A:A[/COLOR]").Find(ComboBox1.Value, , xlValues, [COLOR=#0000ff]xlWhole[/COLOR])
  If Not f Is Nothing Then
    sh.Select
    f.Select
  Else
    MsgBox "Does not exist"
  End If
End Sub

note: If you want to find part of a text inside the cell, change XlWhole to XlPart
 
Upvote 0
It's really frustrating how easy you guys make it look....... works like a charm, perfect. Thank you very much for your time and trouble, bailed me out again.
:)
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,127
Members
453,021
Latest member
Justyna P

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