Buttons to create new rows for multiple tables on same sheet

bnoonan

New Member
Joined
Jan 18, 2022
Messages
6
Office Version
  1. 365
Platform
  1. MacOS
  2. Web
I have scoured the forums, and have come across a few options that are close to what I'm looking for. But, I'm beginning to think that its probably not possible.

I have a sheet that has multiple tables on it. Id like a button on each table that says "Add New Row". When you click on this, it will copy all of the formulas and drop-downs, and create a new blank row. The one thing that I know will be an issue with this is that as a new row is created for Table 1 (at the top), everything below it will shift down...including the buttons associated with the other tables.

Here is an example of what my sheet looks like, and where I was thinking the button placement would be:

Screen Shot 2022-01-18 at 11.43.01 AM.png



Thanks so much ahead of time for looking at this. If it's not possible, I totally understand. Honestly, the default method of Inserting a new row isnt that cumbersome. But I figured that adding a button would be pretty awesome.

and, as menthoned, some of the cells have formulas, and others are drop-down lists. Thus, formulas would need to be copied to the new row.

-Bobby
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This one liner does what you want... Change the names to match your needs...

VBA Code:
Private Sub CommandButton1_Click()
      ActiveSheet.ListObjects("Table1").ListRows.Add AlwaysInsert:=True
End Sub
 
Upvote 0
Thank
This one liner does what you want... Change the names to match your needs...

VBA Code:
Private Sub CommandButton1_Click()
      ActiveSheet.ListObjects("Table1").ListRows.Add AlwaysInsert:=True
End Sub
Thanks for replying so quickly. This would be fantastic if it were this easy. I tried to add your macro to the first button, and receivew an error:

Screen Shot 2022-01-18 at 1.02.29 PM.png


Here is what I see when I click Debug:

Screen Shot 2022-01-18 at 1.03.13 PM.png
 
Upvote 0
Actually sent the wrong screen shot. This is from a different version of your code....but I received the same error. Here is the same error using your code:

Screen Shot 2022-01-18 at 1.06.41 PM.png
 
Upvote 0
What is the name of your Table that you are trying to insert the row on.
 
Upvote 0
I named the table "Table1". (also, im not sure if i should have included the header cells with the table name "TABLE 1".

Screen Shot 2022-01-18 at 1.15.28 PM.png
 
Upvote 0
Is there a space between "Table" and "1". You show it both ways in Post #6. Once on the sheet without a space and once in your comment with a space. Although, I would imagine what is showing on the pic of your sheet is correct. If that is the case and you sheet with Table1 is the active sheet, then it should not throw a Subscript error. I noticed you are working on a Mac. I don't know if perhaps that has something to do with it.

The code I provided will absolutely work on a table named "Table1" on the activesheet in 365 on a Windows machine.
 
Upvote 0
The actual name of the table is without a space (Table1). Row 10 that shows "TABLE 1" will eventually be changed to something like "Server List".
 
Upvote 0
Is you code in the sheet module or in a code module. If its a Private Sub, it must be in the Worksheet Module where the button resides.
 
Upvote 0
Is you code in the sheet module or in a code module. If its a Private Sub, it must be in the Worksheet Module where the button resides.
I tried in both, and still got the same error. I am on a Mac like you mentioned above....so this is probably the issue. Disappointing to say the least...
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,200
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top