Hello-
I'm trying to create a macro that uses a form where someone can search for a part number (or part of a part number) in a field and the macro will search for that part. I'm using the custom autofilter "contains" option to do this.
It works fine, except when someone types in something that returns no results, like SearchWords(jj)="*adafsfd*" I've tried everything to fix it. The line below gives the error
I tried catching that error, but I still get a runtime "No cells were found" Does anyone know how I can fix this? Maybe check if no cells are visible or something?
THANKS IN ADVANCE!
-Jon
I'm trying to create a macro that uses a form where someone can search for a part number (or part of a part number) in a field and the macro will search for that part. I'm using the custom autofilter "contains" option to do this.
Code:
Sheets(MainSheet).Range("$B$1:$O$" & DataLastRow).AutoFilter Field:=Col - 1, Criteria1:= _
SearchWords(jj), Operator:=xlFilterValues
If Sheets(MainSheet).Range(Cells(2, Col), Cells(DataLastRow, Col)).SpecialCells(xlCellTypeVisible).Count > 0 Then
On Error Resume Next
Set FiltRange = Sheets(MainSheet).Range(Cells(2, Col), Cells(DataLastRow, Col)).SpecialCells(xlCellTypeVisible)
On Error GoTo ERR1
End If
Code:
Sheets(MainSheet).Range(Cells(2, Col), Cells(DataLastRow, Col)).SpecialCells(xlCellTypeVisible)
THANKS IN ADVANCE!
-Jon