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
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
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.