Insert and copy row above

pkotzee

New Member
Joined
May 5, 2011
Messages
2
Hi
I have a button that inserts a row above the cell the button is placed in.
Here is the code:

Code:
Sub Button6_Click()
    ActiveSheet.Shapes(Application.Caller).TopLeftCell.EntireRow.Insert
 
End Sub

But I also want to copy all formulas and dropdown lists from specific cells in the row above the new row. Hope it makes sense.

Hope someone will be able to help me.
Peter
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If by dropdown lists, you mean data validation lists, they appear to be copied to the inserted row.

When a row is inserted, it is selected, so a series of commands similar to the following would copy formulas:

Copy formula as if it was dragged down (relative references will change)
Code:
Cells(Selection.Row, "F").FormulaR1C1 = Cells(Selection.Row - 1, "F").FormulaR1C1
Duplicate formula (relative references stay the same)
Code:
 Cells(Selection.Row, "F").Formula = Cells(Selection.Row - 1, "F").Formula
 
Upvote 0

Forum statistics

Threads
1,224,570
Messages
6,179,610
Members
452,931
Latest member
The Monk

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