Am very new to programming. i have a list of trainees and their corresponding info:
I have then developed an excel user form as follows:
where Admin level = district
I am trying to develop simple database to search list entries using the "extract data" button from multiple selections specified by the combobox selections on the user form.
i have managed to write the code for reseting the form using the "Reset" button and saving the output. am struggling to write a code to search the list using user form selection and return all matching entries into a different worksheet. the following code i have done only returns one entry:
The question in summary: how do i perfect this code to take all combobox selections from the user form and display the matching entries (with corresponding information for each matching entry) into another worksheet within the same workbook?
I have then developed an excel user form as follows:
where Admin level = district
I am trying to develop simple database to search list entries using the "extract data" button from multiple selections specified by the combobox selections on the user form.
i have managed to write the code for reseting the form using the "Reset" button and saving the output. am struggling to write a code to search the list using user form selection and return all matching entries into a different worksheet. the following code i have done only returns one entry:
VBA Code:
Sub searchmultiplevalues()
Dim r As Long, c As Long, col_index As Long, lastcol As Long
lastcol = Cells.Find(what:="*", after:=Range("A1"), lookat:=xlPart, LookIn:=xlFormulas, searchorder:=xlByColumns, searchdirection:=xlPrevious, MatchCase:=False).Column
r = 2
col_index = 2
For c = 2 To lastcol
Cells(r, c).Value = Application.WorksheetFunction.VLookup(Range("A2"), Range("A10:E20"), col_index, False)
col_index = col_index + 1
Next c
MsgBox("Search finalized!")
End Sub
The question in summary: how do i perfect this code to take all combobox selections from the user form and display the matching entries (with corresponding information for each matching entry) into another worksheet within the same workbook?