Listbox search at any position

yinkajewole

Active Member
Joined
Nov 23, 2018
Messages
281
I have a listbox that displays the list of files in a folder. i have a textbox that i want to use to search files, for instance, if i should type "ice" it should displays files like "rice, price, apprentice, iceland"
 
@Fluff can you please create a search box for the code
Code:
Private Sub UserForm_Initialize()Dim x As Long, FileNum As Long, TotalFile As String, Lines As Variant
FileNum = FreeFile
Open "c:\Users\History.txt" For Binary As [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL] 
TotalFile = Space(LOF(FileNum))
Get [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL] , , TotalFile
Close [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FileNum"]#FileNum[/URL] 
Lines = Split(TotalFile, vbCrLf)
With ListBox1
For x = UBound(Lines) To 0 Step -1


    .AddItem Split(Lines(x), "|")(0)
    .List(.ListCount - 1, 1) = Mid(Lines(x), InStr(1, Lines(x), "|") + 1)


Next
End With

ListBox1.ColumnWidths = "0;200"
End Sub

the columncount = -1
 
Last edited:
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
This question has nothing to do with your op, so please start a new thread
 
Upvote 0
This question has nothing to do with your op, so please start a new thread

I'm sorry, i thought it still goes along with this thread so as not to have duplication of threads, nevertheless, according to your word, i'll start a new thread, thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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