pivate tables in excel

S

Sean Farrow

Hi:
How can I obtain access via the object model to any pivot tables in the
active worksheet/workbook via code.
Any help appreciated
Cheers
Sean.
 
P

Patrick Molloy

Option Explicit

Sub getPT()
Dim ws As Worksheet
Dim pt As PivotTable

For Each ws In ThisWorkbook.Worksheets

If ws.PivotTables.Count > 0 Then

For Each pt In ws.PivotTables

Debug.Print ws.Name, pt.Name

Next


End If


Next





End Sub
 
P

Patrick Molloy

either you need to save the number externally somewhere or save your workbook
each day.
If you're saving it, then you can use the Workbook's open event to indrement
the cell
in the developement IDE, double click on ThisWorkbook in the Project browser.

add code like this...

Option Explicit
Private Sub Workbook_Open()
Dim target As Range
Set target = Worksheets("Sheet1").Range("B2")
target = target + 1
End Sub
 
P

Patrick Molloy

hmmm interesting - answered a different question and it popped in here/
please ignore!
 
Top