Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a Userform that contains one TextBox and one ListBox. The ListBox will initially contain about 300 unique string values.
If a user types a short substring into the TextBox, I would like to only visually display the lines that contain that substring. Therefore, the items in the ListBox will dynamically change, depending on the substring entered in the TextBox. What would be an efficient way to implement this? Would I have to store the strings in an array and constantly update both the array and ListBox? Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Tatsujin" wrote in message
I have a Userform that contains one TextBox and one ListBox. The ListBox will initially contain about 300 unique string values. If a user types a short substring into the TextBox, I would like to only visually display the lines that contain that substring. Therefore, the items in the ListBox will dynamically change, depending on the substring entered in the TextBox. What would be an efficient way to implement this? Would I have to store the strings in an array and constantly update both the array and ListBox? One of several ways, in a light test this worked for me With sample text in A1:A300, a form with a listbox and textbox, type in the textbox Private Sub TextBox1_Change() Dim i As Long Dim sMatch As String Dim arr arr = Range("A1:A300").Value sMatch = LCase$("*" & Me.TextBox1 & "*") With Me.ListBox1 .Clear For i = 1 To UBound(arr) If LCase(arr(i, 1)) Like sMatch Then .AddItem arr(i, 1) End If Next End With End Sub Peter T |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use a listbox as a dynamic array? | Excel Programming | |||
Dynamic link with 2 dependent listbox? | Excel Discussion (Misc queries) | |||
DYNAMIC LISTBOX | Excel Programming | |||
dynamic fill of listbox - need help | Excel Programming | |||
Dynamic Multi Column ListBox | Excel Programming |