• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Adding new row to table using macro

marcwlms

New Member
Hi

Apologies if this has been covered elsewhere, Am new to vba macros, and i'm struggling to find an answer.

I have a table range in Excel called Objectives.

I want to assign a macro to a command button that will add a new row to the bottom of the table each time it is clicked. Id also like it to keep the formatting that exists in the rows in the table.
 
Hi Marc,

Create a new module and put this in it:
Code:
Sub AddTableRow()

    Selection.ListObject.ListRows.Add AlwaysInsert:=True

End Sub

It adds a row to any currently selected table (click anywhere within the table) if this action is something you do a lot, you might consider going into options, and adding the macro to your ribbon.

Attached example, PS: Use the developer tab, record macro function, it solves simple problems like this, I don't think anybody honestly remembers all of these little functions.
 

Attachments

Hi Thanks for your reply

what i was after is linking the command to a button people could click on to create a row to the table using a button as per the attached file and keep the row formatting in place.

Marc
 

Attachments

  • Capture.PNG
    Capture.PNG
    85.5 KB · Views: 4
Back
Top