pivate tables in excel

  • Thread starter Thread starter Sean Farrow
  • Start date Start date
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.
 
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
 
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
 
hmmm interesting - answered a different question and it popped in here/
please ignore!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top