Command button to copy and insert new row

OrrukHai

New Member
Joined
Oct 25, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello, I've used this forum for a while and it's been super helpful (Thank you!), but this is my first time posting as I can't seem to find that the solution I'm looking for has been discussed before.

I have a sheet with a number of rows that contain formatting and formulas. The cells in the row contains some product types and values that it takes from another sheet using IF.

I'm wanting to add a command button that when clicked, will insert a new row below row 51, based on the formatting and formulas in row 51. The solutions I've found on this forum so far add a new blank row only, without the formatting or formulas copied across.

Is a solution available?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
This must do the trick:
VBA Code:
Sub test()
  Rows(UsedRange.Row).Copy
  Rows(UsedRange.Row).Insert
End Sub
 
Upvote 0
Do you want just only for 51? Then:
VBA Code:
Sub test()
  Rows(51).Copy
  Rows(51).Offset(1).EntireRow.Insert
End Sub
 
Last edited by a moderator:
Upvote 0
Solution

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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