Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By pgc01

VBA to convert table to range

This is a discussion on VBA to convert table to range within the Excel Questions forums, part of the Question Forums category; Dear All, I am looking for VBA to convert a table to a range. I used the macro recorder and ...

  1. #1
    Board Regular
    Join Date
    Dec 2007
    Location
    Oakhurst, New Jersey, USA
    Posts
    442

    Question VBA to convert table to range

    Dear All,

    I am looking for VBA to convert a table to a range. I used the macro recorder and selected the Convert to range option from the Table Ribbon. The resulting macro was completely empty:


    Code:
    Sub Macro2()
    '
    ' Macro2 Macro
    '
    '
    End Sub
    Any ideas?

    Thanks,

    GL

  2. #2
    MrExcel MVP
    Join Date
    Apr 2006
    Posts
    15,709

    Default Re: VBA to convert table to range

    Hi

    Try:

    Code:
        ActiveSheet.ListObjects("MyList").Unlist
    Kind regards
    PGC

    To understand recursion, you must understand recursion.

  3. #3
    Board Regular
    Join Date
    Dec 2007
    Location
    Oakhurst, New Jersey, USA
    Posts
    442

    Question Re: VBA to convert table to range

    pgc01,

    Your code works perfectly.

    The code requires the name of the table. Can you advise what the code would be if you did not know the name of the table? Can you use a wildcard? This code does not work.

    Code:
    ActiveSheet.ListObjects("?").Unlist
    Thanks,

    GL

  4. #4
    MrExcel MVP
    Join Date
    Apr 2006
    Posts
    15,709

    Default Re: VBA to convert table to range

    Hi

    You can also refer to the table using its index in the ListObjects collection. For ex., if you have just defined one table in the active worksheet, try:

    Code:
    ActiveSheet.ListObjects(1).Unlist
    thamestowers likes this.
    Kind regards
    PGC

    To understand recursion, you must understand recursion.

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com