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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,369
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,122,246
Messages
5,595,044
Members
413,963
Latest member
teggl97

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
Top