Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

List All Pivot Tables and It Sources


The following code will loop through all pivot tables in workbook and print Name, Source, Refreshed By, Refreshed on, Sheet name, location of pivot tables.

Sub ListPivotsInfor()

    Dim St As Worksheet

    Dim NewSt As Worksheet

    Dim pt As PivotTable

    Dim I, K As Long

    Application.ScreenUpdating = False

    Set NewSt = Worksheets.Add

    I = 1: K = 2

    With NewSt

        .Cells(I, 1) = "Name"

        .Cells(I, 2) = "Source"

        .Cells(I, 3) = "Refreshed by"

        .Cells(I, 4) = "Refreshed"

        .Cells(I, 5) = "Sheet"

        .Cells(I, 6) = "Location"

        For Each St In ActiveWorkbook.Worksheets

            For Each pt In St.PivotTables

                I = I + 1

                .Cells(I, 1).Value = pt.Name

                .Cells(I, 2).Value = pt.SourceData

                .Cells(I, 3).Value = pt.RefreshName

                .Cells(I, 4).Value = pt.RefreshDate

                .Cells(I, 5).Value = St.Name

                .Cells(I, 6).Value = pt.TableRange1.Address

            Next

        Next

        .Activate

    End With

    Application.ScreenUpdating = True

End Sub

Subscribe

Enter your e-mail below and get notified on the latest blog posts.




Tags

VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts


Follow Us