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 formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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