Application/object defined error 1004 - Autofilter

Jezebelle21

New Member
Joined
Feb 24, 2015
Messages
3
Hi
I'm trying to add an autofilter to a row where the first 3 columns of data are refreshed from an external data source and the next 4 columns of data are formulas (Range A4:G#varies). I can manually add an autofilter to this row outside of VBA, but when I try to use code the subject error occurs. I have code that affects this module in a couple of other modules, but I have tried to reference it all appropriately so that the correct workbook and worksheets are accessed. I would appreciate any advice on my code below (I have tried two ways to autofilter and both produce the same error):

Code:
Public wkbTCWorkbook As Workbook
Set wkbTCWorkbook = ActiveWorkbook
wkbTCWorkbook.Activate 'previous two rows are in a different module and other code is run before this and the following lines
With Worksheets("Active contracts")
    .AutoFilterMode = False
    .PivotTables("ActiveContracts").PivotCache.Refresh
    '.Rows(4).AutoFilter Filter:=4, Criteria1:="=#N/A" ERROR
    '.Range("D4").AutoFilter Filter:=1, Criteria1:="#N/A" ERROR
End With

I feel like this is a silly, simple error, but I just can't wrap my head around the issue. Please don't hesitate to let me know if there is any missing info you might need to resolve.

Kind regards
Erin
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
hi Jezebelle21, welcome to the forum.
I don't recall seeing the autofilter used on rows before. It is normally used to filter column data.
 
Upvote 0
Hi JLGWhiz
I don't know if it's common or not, but it works in another unrelated module of my project! :)
KR
Erin
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,930
Members
449,479
Latest member
nana abanyin

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