I am learning listboxes today My code below populates a listbox from a searched range. Everything works fine but i would like to know how to make this code display 10 columns instead of 2. Thanks for your time.
the column count function doesnt work.
Code
Dim rng As Range
Application.ScreenUpdating = False
On Error Resume Next
With Range("A6").CurrentRegion
.AutoFilter 5, "*" & Me.TextBox1.Text & "*"
Load Userform8
Userform8.LsBx_View.Clear
For Each rng In .Offset(1).Resize(.Rows.Count - 1).Columns(5).SpecialCells(xlCellTypeVisible)
'description as column 1 in the listbox
Userform8.LsBx_View.AddItem rng.Value
'price as column 2
Userform8.LsBx_View.List(Userform8.LsBx_View.ListCount - 2, 1) = rng.Offset(, 1).Value
'row number as column 3
Userform8.LsBx_View.List(Userform8.LsBx_View.ListCount - 1, 2) = rng.Row
Next
.AutoFilter
End With
Unload UserForm3
Userform8.Show
Application.ScreenUpdating = True
Display More