accessing pivot talbes using dom

  • Thread starter Thread starter Sean Farrow
  • Start date Start date
S

Sean Farrow

Hi:
How can I enumerate all he pivot tables in a work book using the dom/vb
code?
Cheers
Sean.
 
Hi Sean,

Below is the vba code that you can use to walk through each PT in a workbook.

Sub enumeratePT()
Dim ws As Worksheet
Dim pt As PivotTable
For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
ws.Select
For Each pt In ws.PivotTables
Debug.Print pt.Name
' pt.PageFields("COLUMN1").DataRange = "VALID VALUE IN COLUMN1"
' pt.PageFields("COLUMN2").DataRange = "VALID VALUE IN COLUMN2"
Next pt
End If
Next
End Sub

Hong Quach
 
Hi:
Just what I needed.
Sean.
Hong Quach said:
Hi Sean,

Below is the vba code that you can use to walk through each PT in a
workbook.

Sub enumeratePT()
Dim ws As Worksheet
Dim pt As PivotTable
For Each ws In ThisWorkbook.Worksheets
If ws.Visible = xlSheetVisible Then
ws.Select
For Each pt In ws.PivotTables
Debug.Print pt.Name
' pt.PageFields("COLUMN1").DataRange = "VALID VALUE IN
COLUMN1"
' pt.PageFields("COLUMN2").DataRange = "VALID VALUE IN
COLUMN2"
Next pt
End If
Next
End Sub

Hong Quach
 

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