Advanced filter automatically

xyz88

New Member
Joined
Jun 17, 2019
Messages
2
Hi,
I'm trying to set up an advanced filter that updates automatically and here's my code:

Sub advancedfilter()


Sheets("Sheet1").Range("A9:N151").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Sheet1").Range("K1:K2"), _
CopyToRange:=Sheets("Sheet2").Range("A8:N8") _
, Unique:=False


End Sub



I keep on getting the error 1004 - method of range fail. If i could please get some help on what the issue may be that would be much appreciated!

Thank you!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi & welcome to MrExcel.
You're code works for me.
Are either of the sheets protected?
Also do you have any merged cells?
 
Upvote 0
Thanks for getting back to me! the sheets are not protected and i don't have any merged cells.
Would there be any other reasons why this doesn't work?
 
Upvote 0
In that case I can't think of any other reason why you'd get a 1004 error
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,027
Members
448,543
Latest member
MartinLarkin

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