Advanced Filter Macro works until I run a different Advanced Filter Macro in same workbook

rdarrylhudson

New Member
Joined
Mar 19, 2024
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
As the title states, I am running an advanced filter macro that works for a while, but stops working with a error 1004 "advancedfilter method of range class failed". This appears to start happening after I run a different advanced filter macro in the same workbook. Here are all the macros I have in the workbook.

The Pivot_Update sheet it filters from:

1710860139699.png


What the pages to copy into look like
1710860179826.png



I can run the "Adv_Filter" on a certain page or I can run the Run_All to go through several pages that need the data. Why does it work for a while, then start giving me the error.

VBA Code:
Sub Adv_Filter()
        
        Sheets("Pivot_Update").Range("Q4:U1048576").AdvancedFilter Action:= _
        xlFilterCopy, CriteriaRange:=Range("D1:D2"), CopyToRange:=Range( _
        "B5:F1048576"), Unique:=False
        
     Cells.EntireColumn.AutoFit
     Call Adv_Filter_current
  

End Sub


Sub Run_All()

Sheets("Allen Grant").Select
    Call Adv_Filter
       
    Call Next_Sheet
 
End Sub


Sub Next_Sheet()
On Error Resume Next
Sheets(ActiveSheet.Index + 1).Activate
If Err.Number <> 0 Then Exit Sub
    Call Adv_Filter
   
    Call Next_Sheet
End Sub



Sub Adv_Filter_current()

    Sheets("Pivot_Update").Range("Y4:AC104865").AdvancedFilter Action:=xlFilterCopy, _
        CriteriaRange:=Range("d1:d2"), CopyToRange:=Range( _
        "N5:R104865"), Unique:=False
        
        Cells.EntireColumn.AutoFit
    
    Call Adv_Filter_Combine
    

End Sub


   



Sub Adv_Filter_Combine()
'
' Adv_Filter_Combine
'
'    Call Delete_old_Current
  
    Range("N5:s978").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
        "S1:S2"), CopyToRange:=Range("B1000:g1048576"), Unique:=False
       
    
    Call Delete_Current_Amounts_After_Copy
    Call Sort_Combined
        
        
End Sub
Sub Delete_Current_Amounts_After_Copy()
'
' Move_Current Macro
'

'
    Range("C1000:C1048576").Select
    Selection.ClearContents
     Range("g1000:g1048576").Select
    Selection.ClearContents
    
    Range("a1000:f1000").Select
    Selection.ClearContents
    
End Sub


Sub Delete_old_Current()
'
' Delete_old_Current Macro
'

'
        Range("A1000:F1048576").Select
    Selection.ClearContents
End Sub



Sub Sort_Combined()
'
' Sort_Combined Macro
'

Range("B6:F3050").Sort Key1:=Range("B6"), Order1:=xlAscending, Header:=xlNo


Dim ws As Worksheet

For Each ws In ActiveWorkbook.Sheets
ws.Activate
ws.[a1].Select
ActiveWindow.Zoom = 100
Next ws
ActiveWorkbook.Worksheets(1).Activate

End Sub

Thank for any help
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,224,885
Messages
6,181,587
Members
453,055
Latest member
cope7895

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top