Pivot Table Questions

FROGGER24

Well-known Member
Joined
May 22, 2004
Messages
704
Office Version
  1. 2013
  2. 2010
Platform
  1. Windows
Is there away to make the ranges variable length-the number of columns will be the same

<ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R1C1:R297C50", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:="", TableName:="PivotTable1", DefaultVersion _
:=xlPivotTableVersion10
< Cells(3, 1).Select


When I run the macro that I recorded, the code stops on this segment of code--giving an error message "Unable to get PivotTables property of the worksheet class."
ActiveSheet.PivotTables("PivotTable1").PivotFields("Ship Or Barge"). _
CurrentPage = "Ship"

Appreciate any help that is given!!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
The best approach in most situations is to use a Dynamic Named Range as the reference to the PivotTable's Datasource.

Contextures' Site has a good explanation on how to use Dynamic Named Ranges as the source for your PivotTables.

http://www.contextures.com/xlpivot01.html

The instructions are based on Excel 2003, but the formulas and concept works in later versions with merely different dialog windows to define names.
 
Upvote 0

Forum statistics

Threads
1,223,521
Messages
6,172,815
Members
452,482
Latest member
Maverick007

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