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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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