run-time error '1004: unable to get the pivottables property of the worksheet class

sighsigh

New Member
Joined
Jun 22, 2016
Messages
2
Hello,

I know you're probably tired of all the 1004 questions, but i'm just puzzled!

The goal of the code is simple: fill all date (pivottables, pivot charts, normal tables, etc), to only show "J1" or "Samsung J1".
The odd thing is, i can run this code once, perfectly, and than not anymore (i get the error). If i remove the filter from the pivot, i can run it again, but only once :s. Any ideas why this would happen?

' Sheets("Pivot").Select
ActiveSheet.PivotTables("PivotTable4").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("PivotTable4").PivotFields("Type").CurrentPage = "J1"
Sheets("Charts").Select
ActiveSheet.PivotTables("Standard Chart").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("Standard Chart").PivotFields("Type").CurrentPage = _
"J1"
Sheets("Results by week").Select
ActiveSheet.PivotTables("PivotTable8").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("PivotTable8").PivotFields("Type").CurrentPage = "J1"
Sheets("ActivationsMigMNP").Select
ActiveSheet.PivotTables("PivotTable10").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("PivotTable10").PivotFields("Type").CurrentPage = "J1"
Sheets("Sales").Select
ActiveSheet.Range("$M$1:$AI$1002").AutoFilter Field:=17, Criteria1:="J1"
Sheets("Orders").Select
Range("J1001").Select
ActiveSheet.Range("$A$1:$J$1000").AutoFilter Field:=6, Criteria1:= _
"Samsung J1"
End Sub



Same for the one where i filter on P8 instead:
' Sheets("Pivot").Select
ActiveSheet.PivotTables("PivotTable4").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("PivotTable4").PivotFields("Type").CurrentPage = "P8"
Sheets("Charts").Select
ActiveSheet.PivotTables("Standard Chart").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("Standard Chart").PivotFields("Type").CurrentPage = _
"P8"
Sheets("Results by week").Select
ActiveSheet.PivotTables("PivotTable8").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("PivotTable8").PivotFields("Type").CurrentPage = "P8"
Sheets("ActivationsMigMNP").Select
ActiveSheet.PivotTables("PivotTable10").PivotFields("Type").ClearAllFilters
ActiveSheet.PivotTables("PivotTable10").PivotFields("Type").CurrentPage = "P8"
Sheets("Sales").Select
ActiveSheet.Range("$M$1:$AI$1002").AutoFilter Field:=17, Criteria1:="P8"
Sheets("Orders").Select
ActiveSheet.Range("$A$1:$J$1000").AutoFilter Field:=6, Criteria1:= _
"Huawei P8"
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
oh, it should be worth mentionning that the error apparantly takes place at the second line of code.
ActiveSheet.PivotTables("PivotTable4").PivotFields("Type").ClearAllFilters
 
Upvote 0

Forum statistics

Threads
1,216,045
Messages
6,128,484
Members
449,455
Latest member
jesski

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