Buying guide test.xlsm
Sub FindKeywords()
Dim wsData As Worksheet
Set wsData = Sheets("Data")
With Sheets("Results")
If IsEmpty(.Range("F3")) Then
MsgBox "Missing keyword in cell F3 ", vbExclamation, "Invalid Keyword Entry"
Exit Sub
ElseIf IsEmpty(.Range("I3")) Then
MsgBox "Please select a state in cell I3 ", vbExclamation, "Missing State Entry"
Exit Sub
End If
Application.ScreenUpdating = False
'Filter data
wsData.AutoFilterMode = False
wsData.UsedRange.AutoFilter Field:=16, Criteria1:="*" & .Range("F3").Value & "*"
wsData.UsedRange.AutoFilter Field:=1, Criteria1:=.Range("I3").Value
If wsData.Range("A" & Rows.Count).End(xlUp).Row = 1 Then
MsgBox "No data matches the filter critera. ", vbInformation, "No Data Match"
Else
'Clear previous data match
If .Range("A" & Rows.Count).End(xlUp).Row > 5 Then
.Rows("6:" & .Range("A" & Rows.Count).End(xlUp).Row).ClearContents
End If
'Copy filtered data
wsData.AutoFilter.Range.Offset(1).Copy Destination:=.Range("A6")
End If
wsData.AutoFilterMode = False
Application.ScreenUpdating = True
End With
End Sub
Bookmarks