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):
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
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