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:
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

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. :)
 

Watch MrExcel Video

Forum statistics

Threads
1,119,144
Messages
5,576,326
Members
412,716
Latest member
thviid
Top