I was unable to find a similar question to this. Basically, I have an excel macro that I have ran probably hundreds of times and has been working fine up until today. Today, when I run it, I get a run-time error 91, object block not set.
The issue begins at this statement: quidTab.AutoFilter.Sort.SortFields.Clear
Does anybody have any advice? I am truly lost
Here is the code:
' Remove The flags that have not triggered on this QUID.
Sub RemoveEmptyFlags()
'
' removeEmptyFlags2 Macro
'
Dim filterRow As Integer, notTriggeredFlagRow As Integer, quidTab As Worksheet
Range("A1").Select
Cells.Find(What:="CE_", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
filterRow = ActiveCell.Row - 1
Rows(CStr(filterRow) & ":" & CStr(filterRow)).Select
Selection.AutoFilter
Set quidTab = ActiveWorkbook.ActiveSheet
quidTab.AutoFilter.Sort.SortFields.Clear
quidTab.AutoFilter.Sort.SortFields.Add _
Key:=Range("C" & CStr(filterRow)), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortTextAsNumbers
With quidTab.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Find the start of the flags that have not triggered, and delete down.
Range("C" & CStr(filterRow)).Select
Cells.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
notTriggeredFlagRow = ActiveCell.Row
If ActiveCell.Row > filterRow Then
Rows(CStr(notTriggeredFlagRow) & ":" & CStr(ActiveWorkbook.ActiveSheet.UsedRange.Rows.Count)).Select
Selection.Delete Shift:=xlUp
End If
Range("A1").Select
End Sub