Results 1 to 5 of 5

Macro for deleting all rows in table

This is a discussion on Macro for deleting all rows in table within the Excel Questions forums, part of the Question Forums category; I am having trouble deleting all the rows within a table. I have a table with an indefinite amount of ...

  1. #1
    Board Regular
    Join Date
    Aug 2009
    Location
    SLC, Utah
    Posts
    554

    Question Macro for deleting all rows in table

    I am having trouble deleting all the rows within a table. I have a table with an indefinite amount of rows of data. I want to select the table and delete all the rows of data in order to replace it with another indefinite amount of data. Here is the macro I recorded but it only deletes the first row. Any ideas?

    Code:
    Sub Macro2()
    '
    ' Macro2 Macro
    '
    
    '
        Range("Table8[A]").Select
    Selection.ListObject.ListRows(1).Delete
    End Sub
    Thank you!

    Nicole

  2. #2
    Board Regular
    Join Date
    Jul 2006
    Location
    Brussels
    Posts
    7,644

    Default Re: Macro for deleting all rows in table

    Perhaps:

    Code:
    Selection.Cells(1).CurrentRange.EntireRow.Delete
    Place your cursor in the tab. Please test this on a COPY OF YOUR FILE.
    Regards,


    Wigi


    Excel MVP 2011-2014



    For more Excel memes: visit http://www.wimgielis.be ==> English articles ==> Excel memes

    -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

  3. #3
    Board Regular
    Join Date
    Aug 2009
    Location
    SLC, Utah
    Posts
    554

    Default Re: Macro for deleting all rows in table

    Just figured it out - I feel really good about myself . I adjusted your code and came up with this:
    Code:
    Sub Macro2()
    '
    ' Macro2 Macro
    '
    
    '
        Range("Table8[A]").Select
    Selection.EntireRow.Delete
    End Sub
    Thanks
    Nicole
    Last edited by nicolewh; Aug 24th, 2009 at 03:41 PM.

  4. #4
    Board Regular
    Join Date
    Jul 2006
    Location
    Brussels
    Posts
    7,644

    Default Re: Macro for deleting all rows in table

    Well done!

    But this is sufficient:

    Code:
    Sub Macro2()
        Range("Table8[A]").EntireRow.Delete
    End Sub
    Select's only (marginally) slow down macro execution.
    Regards,


    Wigi


    Excel MVP 2011-2014



    For more Excel memes: visit http://www.wimgielis.be ==> English articles ==> Excel memes

    -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

  5. #5
    Board Regular
    Join Date
    Aug 2009
    Location
    SLC, Utah
    Posts
    554

    Default Re: Macro for deleting all rows in table

    Thank you so much!

    Nicole

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