Get Table names from excel sheet

Hello, I have a pivot table in an excel file, I need some code that can return a list of all the tables\pivot tables in the sheet.

Is this possible?

thanks for the help :smiley:

Hi! @Cody_Barber,

you can change the excel to pivot table. but you can’t access the pivot table using UIPath.

Regards,
NaNi

Thanks for the quick reply, I’m looking into writing some VBA code to return all the tables at the moment.

Hi

Check for this code

Dim PT As PivotTable
For Each PT In ActiveSheet.PivotTables
MsgBox PT.Name
Next

Use it in invoke code activity

Cheers @Cody_Barber

1 Like

Hi,

I created this code and it seems to work…


    Dim xTable As ListObject

    Dim xSheet As Worksheet

    Dim I As Long

    I = -1

    For Each xSheet In Worksheets
        if xSheet.Name = ActiveSheet.name Then
            For Each xTable In xSheet.ListObjects
                I = I + 1
                Sheets("Table Name").Range("A1").Offset(I).Value = xTable.Name
            Next xTable
        End if
    Next
End Sub

It outputs the list in a Sheet called “Table Name” witch i am creating before i invoke the code in UiPath