JohnSmith9945
New Member
- Joined
- Sep 30, 2022
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
Hey! im really struggling to understand how, based on a combobox selection i can pull records into a listbox. Ive tried the below code based on some videos but it still doesnt quite make sense/isnt doing what i need it too.
i just want to to be able to select an ID in the combo box, press apply filter and have that search my table and display all records that have that ID in their row, in the list box.
Any help would be much appreciated!
i just want to to be able to select an ID in the combo box, press apply filter and have that search my table and display all records that have that ID in their row, in the list box.
Any help would be much appreciated!
VBA Code:
Option explicit
Dim my data As range
Private sub applyfilternav_click ()
Set mydata = Worksheets ("dataID").range ("A1").CurrentRegion
Me.Combobox1.list =mydata.Offset(1).Value
Me.Listbox1.ColumnCount = 13
Me.Listbox1.Columnheads = true
Me.Listbox1.ColumnCount = "10,10,10,10,10,10,10,10,10,10,10,10,10"
Dim mysearchrng as range
Dim myfindrange as range
Dim myvaltofind as variant
With Worksheets("DataIssues")
myvaltofind =combobox1.value
set mysearchrng =.Columns("C)
end with
set myfindrng = mysearchrng.find(what:=myvaltofind, _
Lookat:=xlwhole, _
Searchorder: = xlByrows, _
Searchdirection: =xlnext, _
matchcase: =false)
Listbox1.additem
with listbox1
.list (.listcount -1, 2)= myfindrng.value
.list (.listcount -1, 0)= myfindrng.offset (0,1).value
.list (.listcount -1, 1)= myfindrng.offset (0,2).value
.list (.listcount -1, 3)= myfindrng.offset (0,4).value
private sub userform_intialize()
combobox1.list = worksheets("detailsID").range("b2:100").value
end sub