View Full Version : Need help : fill listbox with search result
skan19
04-29-2018, 07:08 AM
Hi all,:hi:
I am looking for some help with VBA, i have textbox and listbox
i want to populate a listbox in a userform based with search result with find function
Option Explicit
Private Sub CommandButton1_Click()
Dim r As Range
Dim c As Range
Dim f As String
Set r = Worksheets("Sheet1").UsedRange
With ListBox1
.Clear
.ColumnCount = 2
.ColumnWidths = "30;300"
Set c = r.Find(TextBox1.Text, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
f = c.Address
Do
.AddItem c.Address(0, 0)
.List(.ListCount - 1, 1) = c.Value
Set c = r.FindNext(c)
Loop Until c.Address = f
End If
End With
End Sub
skan19
04-30-2018, 06:33 AM
Thank you so much : pray2: mana , after adaptation it work
but on the first listbox column it give me a cell address of search result
i have a table with ID , Name and birthday date,
i want it to display all this criteria on the same line
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.