Search 1
Continue with Search 2
And a Search button to perform the autofilter action
Private Sub CommandButton1_Click() 'Search button
Dim rData As Range
With Sheet1
Set rData = .Range(.Cells(1, 1), .Cells(.Rows.Count, 8).End(xlUp))
If Not .AutoFilterMode Then .Cells(1, 1).AutoFilter
.Cells(1, 1).AutoFilter Field:=lFld, Criteria1:=sCrit
'Header
On Error Resume Next
Set rSource = .AutoFilter.Range.SpecialCells(xlCellTypeVisible)
ActiveSheet.AutoFilterMode = False
On Error GoTo 0
.Cells(1, 200).CurrentRegion.ClearContents
rSource.Copy .Cells(1, 200)
Set rSource = .Cells(2, 200).CurrentRegion
Set rSource = rSource.Offset(1, 0).Resize(rSource.Rows.Count - 1, _
rSource.Columns.Count)
End With
With Me.ListBox1
.RowSource = ""
.RowSource = rSource.Address(external:=True)
End With
End Sub
They work perfectly if I autofilter them at a field and a criteria one at a time. Now my question is how can I autofilter the optionbutton and then continue and filter the data for combobox?
Edited: my listbox does not seem to update accordingly with the excel after search 2. How can I amend my code such that it will refresh from the first search and list out the updated search 2 result? Please advise.