Advanced filter from closed workbook

rosanel

New Member
Joined
Aug 30, 2016
Messages
1
Hi,


I am trying to pull data from a closed workbook using advanced filter.


here is what my code looks like right now. It works fine if I have both the workbook with the criteria as well as the workbook "ORDERS CHART" open


Code:
    Sub Macro1()
        Range("Sheet2!A1:AU999").Clear
    Range("'C:\Users\yrosanel\Downloads\[ORDERS CHART.xls]Data'!A1:AU999").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
        "J1:K2"), CopyToRange:=Range("Sheet2!A1:AU1"), Unique:=False
    End Sub
However, if "ORDERS CHART" is closed, I get the following error:


Run-time error '1004':
Method 'Range' of object'_Global' failed

Any help would be greatly appreciated! I have been stuck for days!
 

Forum statistics

Threads
1,226,871
Messages
6,193,443
Members
453,799
Latest member
shanley ducker

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