How do I search the next column over list index?

VBE313

Well-known Member
Joined
Mar 22, 2019
Messages
686
Office Version
  1. 365
Platform
  1. Windows
Sub TextBox4_Change()
sFind = Me.TextBox4.text
If Len(sFind) = 0 Then
Me.ListBox4.ListIndex = -1
Me.ListBox4.TopIndex = 0
Else
For I = 0 To Me.ListBox4.ListCount - 1
If InStr(UCase(ListBox4.List(I)), UCase(sFind)) > 0 Then
Me.ListBox4.TopIndex = I
Me.ListBox4.ListIndex = I
Exit For
End If
Next I
End If
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How about
Code:
If InStr(UCase(ListBox4.[COLOR=#ff0000]List(i, 1)[/COLOR]), UCase(sFind)) > 0 Then
 
Upvote 0
Thanks Fluff!
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
Fluff, would you know how to select the next match?

Thanks,
 
Upvote 0
Like
Code:
   For i = 0 To Me.ListBox4.ListCount - 1
      If InStr(UCase(ListBox4.List(i, 1)), UCase(sFind)) > 0 Then
         j = j + 1
         If j = 2 Then
            Me.ListBox4.TopIndex = i
            Me.ListBox4.ListIndex = i
            Exit For
         End If
      End If
   Next i
 
Upvote 0
Fluff, Thank you again! For some reason it only selects the next match, can I go to another match and another match? Thanks
 
Upvote 0
Not when you are running it from a Textbox change event.
 
Upvote 0
What if you run it through a command button?
 
Upvote 0
I now see you have started a new thread for this requirement using a command button.
All posts relating to selecting the next item must go on the other thread.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

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