Hi All,
I'm very new to VBA and try to resolve most of my problems through looking at everyone's helpful posts! however, this time I can't seem to figure it out. I am trying to find "TS" in a specific column and filter for those rows if available. If not available, I just want to exit the sub. However, I keep getting a run time error 91 saying "object variable or with block variable not set." I have included my code below and am hoping someone can help
I'm not sure what happened because it worked at first, but now I'm receiving the error.
I'm very new to VBA and try to resolve most of my problems through looking at everyone's helpful posts! however, this time I can't seem to figure it out. I am trying to find "TS" in a specific column and filter for those rows if available. If not available, I just want to exit the sub. However, I keep getting a run time error 91 saying "object variable or with block variable not set." I have included my code below and am hoping someone can help
Code:
Sub CleanUp()
'
'Clean Up Macro
'
Dim rng As Range
Set rng = Range("AP:AP")
Dim rngFound As Range
Set rngFound = rng.Find("TS")
If rngFound > 0 Then 'error brings me here
Range("AP:AP").AutoFilter Field:=42, Criteria1:="TS"
ActiveSheet.AutoFilter.Range.Offset(1, 0).Rows.SpecialCells(xlCellTypeVisible).Delete (xlShiftUp)
ActiveSheet.AutoFilter.ShowAllData
End If
End Sub
[\code]