Code:
Sub Practicereport()
Dim markdata As String: markdata = Sheets("Main").Range("C1").Value
Dim lastrow As String: lastrow = Sheets("Data3").Range("A1000000").End(xlUp).Row
Sheets("Data3").Select
Range("A1:B1").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$" & lastrow).AutoFilter Field:=2, Criteria1:= _
"<" & markdata, Operator:=xlAnd
Range("B2:B" & lastrow).SpecialCells(xlCellTypeVisible).Select
On Error Resume Next
Selection = "NG"
ActiveSheet.ShowAllData
End Sub
The code is looking at the main page's value(markdata) and then filter with markdata on A and B columns in data3 sheet, then put NG in B column cells if markdata exist in A column.
This code works fine when I have data after filtering, but if I do not have data after filtering, it gives me an error.
Is there any way to skip code, if filter is blank?
Thank you!