ApolloCarrierServ
New Member
- Joined
- May 3, 2019
- Messages
- 23
I have a worksheet I am trying to create a filter for. I recorded a macro with all of the filtering set to what I need. When I try to assign it to my ComboBox and run it I am getting a Run-Time Error 91 Object variable or with block variable not set. It is highlighting the section " ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Clear"
Here is my Code:
Any help with this is appreciated.
Here is my Code:
Code:
Sub FOLLOWUP()
'
' FOLLOWUP Macro
'
'
If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Clear
ActiveSheet.ShowAllData
ActiveSheet.Range("$D$13:$T$1880").AutoFilter Field:=4, Criteria1:= _
"FOLLOW UP"
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Add Key _
:=Range("P14:P1880"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Add Key _
:=Range("N14:N1880"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Add Key _
:=Range("M14:M1880"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Add Key _
:=Range("H14:H1880"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort.SortFields.Add Key _
:=Range("E14:E1880"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Active Leads").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End If
End Sub
Any help with this is appreciated.