Dynamic Pivot Table Source

Exer

New Member
Joined
Apr 12, 2011
Messages
2
Hi, I've had a look around the forums and can't find a solution to my problem, I hope somebody can help :)

I have a list of data in workbook "Data" and I want to have a pivot table in workbook "Pivot" pick up this data.

The problem is I want the source of the pivot table to change according to how many rows in the data sheet have values.

My initial solution was to use a named data range, but that doesn't work unless both workbooks are open.

My 2nd solution was to have a cell in the pivot table workbook return the number of rows in the data workbook with values:
Code:
=MATCH(1E+306,'[Data.xls]Sheet1'!$A:$A,1)
This works, so now I tried to have the pivot tables source range updating according to this value and I got stuck. The code im trying to use is:
Code:
ActiveSheet.PivotTableWizard SourceType:=xlDatabase, SourceData:= _         "'C:\[Data.xls]Sheet1'!R1C1:R[COLOR=Red]3[/COLOR]C13"
I need the number I've highlighted in red above to change according to value of a cell in the same worksheet.

Thanks in advance for any help
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Any ideas?

I get the feeling using code from the wizard was a bad idea but I didn't know how else to change the source of a pivot table.
 
Upvote 0

Forum statistics

Threads
1,224,584
Messages
6,179,691
Members
452,938
Latest member
babeneker

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