List box show selected row

bugcatchup

New Member
Joined
Oct 7, 2005
Messages
17
I have a form open on the same page the data is on. The form has a listbox which is multi columned and contains many rows. I have a Search box that will search and find when you type in say, Br. It will find the 1st row that starts with Br. The problem is that since the list box is so long if the data being searched for and found is not already showing in the list box window, I have to manually scroll to it. How do I make the selected row show in the list box window without scrolling?

Thanks :confused:
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Fat Cat

Active Member
Joined
Nov 5, 2004
Messages
336
Is it the ListBox contents your are searching through or the data on the worksheet ?

If it is data on the worksheet, the corresponding row in the ListBox would probably be the worksheet row number - 1

eg: if your data was found on worksheet row 134,
ListBox1.ListIndex = (134 - 1)

If it is the listbox you search through, just set the ListBox.ListIndex to the row number that you found your data on.
eg:
Code:
Dim myText As String

myText = "whatever"
For i = 0 To ListBox1.ListCount - 1
    If UCase(ListBox1.List(i, 0)) = UCase(myText) Then
        ListBox1.ListIndex = i
        Exit For
    End If
Next i
 

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, bugcatchup,

first of all I would experiment a bit with comboboxes,
they can scroll to the items you are typing in

would this do what you need ?
kind regards,
Erik
 

bugcatchup

New Member
Joined
Oct 7, 2005
Messages
17
I will try both of your ideas tomorrow and let you know what happened.

Thanks for such quick help. :)
 

bugcatchup

New Member
Joined
Oct 7, 2005
Messages
17
I used a drop down validation list to filter all data into smaller categories. When the user selects a row of filtered data a macro copies and paste it to another sheet.

So right now it's doing everything I need it to do.


Thanks for your input again. :)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,631
Messages
5,832,768
Members
430,166
Latest member
Nige Leeming

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
Top