Pivottable Location Property

Ziggy12

Active Member
Joined
Jun 26, 2002
Messages
365
In Excel 2007. How do I step through pivot tables on one worksheet and get the locaton of each.
Tried this but it return an error at XXXX
Sub CreatePictures()
Dim Pt As PivotTable
Dim Ws As Worksheet
Dim Loc(20) As String

Set Ws = Sheets("Summary pivots by DRG")
Ws.Activate

test = Ws.PivotTables.Count
x = 0
For Each Pt In Ws.PivotTables
x = x + 1
Loc(x) = Pt.Location 'XXXX
Next

End Sub

cheers
ziggy
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

What do you mean by "location"? If you mean the cell address then you could use something like this. This returns where the pivot table body starts. You could also use PageRange object if you want to refer to where the Page Fields are located.


HTH
DK

Code:
Sub CreatePictures()
Dim Pt As PivotTable
Dim Ws As Worksheet
Dim Loc(20) As String

Set Ws = Sheets("Summary pivots by DRG")
Ws.Activate

test = Ws.PivotTables.Count
x = 0
For Each Pt In Ws.PivotTables
x = x + 1
Loc(x) = Pt.DataLabelRange.Cells(1, 1).Address
Next

End Sub
 
Upvote 0
Thanks for that
The location property is in xl 2007

PivotTable.Location Property
Gets or sets a String that represents the top-left cell in the body of the specified PivotTable. Read/write.
Version Information
Version Added: Excel 2007

Syntax

expression.Location

expression A variable that represents a PivotTable object.

Maybe it doesn't work on all versions.

cheers
ziggy
 
Upvote 0
Thanks for the inspiration I found tablerange2 after a bit more digging around.

Sub PictPaster()
Dim Pt As PivotTable
Dim Ws As Worksheet

Set Ws = Sheets("Summary pivots by DRG")
Ws.Activate

For Each Pt In Ws.PivotTables
Range(Pt.PageRange.Address).PivotTable.TableRange2.Select
Selection.CopyPicture
Cells(Pt.PageRange.Row + 50, Pt.PageRange.Column).Select
Selection.PasteSpecial
Next
End Sub

cheers
ziggy
 
Upvote 0
OK, glad you got it sorted. I just checked an it looks like the Location property was added in 2007. Seems a little un-necessary when this information was already available using the Address of one of the various range objects in the pivot table.

Cheers
DK
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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