none
Get Workbook FileName from Table ListObject RRS feed

  • Question

  • I have a Sub that has a table ListObject.  I need to get the worksheet and workbook that contains this table.  How do I do that?

    Here's some pseudo code:

    Private Sub DoSomething(table As ListObject)
         Debug.Print(table.Workbook.FileName)
    End Sub


    Ryan

    Saturday, December 14, 2019 5:31 PM

All replies

  • Use table.Parent to refer to the worksheet, and table.Parent.Parent to refer to the workbook. Code could look like this:

    Private Sub DoSomething(table As ListObject)
        Debug.Print "List Object: " & table.Name
        Debug.Print "Worksheet: " & table.Parent.Name
        Debug.Print "Workbook: " & table.Parent.Parent.Name
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Saturday, December 14, 2019 7:39 PM