Add new row to bottom of existing table using Excel VBA

Anonymous
2020-06-30T17:39:19+00:00

How do I add a new row to the bottom of an existing table using Excel VBA? I want to attach this function to an active control box.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2020-06-30T17:52:53+00:00

    Hi Megan

    If your Table is an Excel Table like the one in the sample picture below

    Then try this code

    ******************************************************************************************

    Sub AddRowToTable()   

    Dim ws As Worksheet

    Dim tbl As ListObject

    Set ws = ActiveSheet

    Set tbl = ws.ListObjects("The Name of your table")

    tbl.ListRows.Add   '' This line will add a row at the end of the table

    End Sub

    **************************************************************************************************

    Replace "The Name of your table" with the real name of the table on your side.

    Do let me know if you need more help

    On the other hand,

    If the answer helped you.

    Please, consider marking this thread as answered.

    It would help others in the community with similar questions or problems.

    Thank you in advance

    Regards

    Jeovany

    63 people found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful