Updating PivotTable, why is the sourcedata limited?

RustE

New Member
Joined
Jun 3, 2009
Messages
2
Hi,

I'm working in excel 2007 but I appear to have a problem associated with the row limit from excel 2003. Can't figure it out exactly-

This code snippet works- it updates the pivottable with the order data from LargeModel, which is an input earlier


Code:
 ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
        PivotCaches.Create(SourceType:=xlDatabase, SourceData:=Workbooks(LargeModel).Worksheets("OrderData").Range("A1:J65536") _
        , Version:=xlPivotTableVersion12)

However, if I try to enter a larger number than 65536, I get a "type mismatch" error. I guess this is the row limit from excel 2003, but I'm using 2007, so I don't know what's causing the error. :confused:

Any ideas?

Thanks!!
 

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.

Andy B

Active Member
Joined
Mar 26, 2009
Messages
336
Have you checked to see if you have more than 65536 rows in your spreadsheet? If not (because it was previously a 2003 workbook) you will have to select Convert from the office button to unlock the extra rows.
 

RustE

New Member
Joined
Jun 3, 2009
Messages
2
I checked on it, it is in 2007 and has more than 65536 rows.

I figured out a solution, so I'll post that:

Instead of entering the data range with range("A1:J100000"), this method seems to work. Thanks macro-recorder!
Putting in the extra [ and ] was something I hadn't thought of, but I think it needs them.

Code:
ActiveSheet.PivotTables("PivotTable2").ChangePivotCache ActiveWorkbook. _
        PivotCaches.Create(SourceType:=xlDatabase, SourceData:="[" & LargeModel & "]Order Data!C1:C10")
 

Watch MrExcel Video

Forum statistics

Threads
1,132,783
Messages
5,655,273
Members
418,184
Latest member
snoogz2

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
Top