Advanced Filter copy to another sheet (Best Practice)..

Sleeplol

Board Regular
Joined
Apr 10, 2019
Messages
117
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello Everyone,

I'm running AF from Sheet4 ("Dashboard") with data from Sheet3 ("MainDATA")

Currently the filter runs on the Sheet3 then the results are transferred to Sheet4.
In order to do this, however, I am activating Sheet3 then at the end of the code activating Sheet4.

It works, but slows the code by a bit. Is there a more intelligent way of going about this?

VBA Code:
Sub DashAF()

With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

Sheet3.Activate

    Application.CutCopyMode = False
    Application.CutCopyMode = False
  
    Range("MainData[#All]").AdvancedFilter Action:=xlFilterCopy, CriteriaRange _
        :=Range("BC2:BP3"), CopyToRange:=Range("CA2:CM2"), Unique:=False

    Call TransferDashSort 'this transfers the results to the Dashboard on Sheet4
   
Sheet4.Activate

With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With

End Sub
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,292
Office Version
  1. 2019
Platform
  1. Windows
Hi,
If you qualify your ranges then the filter should be all that is needed

Untested but try this update to your code & see if does what you want

VBA Code:
Sub DashAF()


  
    Sheet3.Range("MainData[#All]").AdvancedFilter Action:=xlFilterCopy, _
                                                  CriteriaRange:=Sheet3.Range("BC2:BP3"), _
                                                  CopyToRange:=Sheet4.Range("CA2"), _
                                                  Unique:=False

End Sub

Dave
 

Sleeplol

Board Regular
Joined
Apr 10, 2019
Messages
117
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Yup, that does it! Much cleaner
Thanks Dave!
 

Watch MrExcel Video

Forum statistics

Threads
1,119,168
Messages
5,576,507
Members
412,730
Latest member
Sebastien Frederic
Top