Macro/VBA To insert new blank row above the selected row

genestoy

New Member
Joined
Jul 30, 2010
Messages
5
I have looked everywhere trying to find a macro or vba that will copy the selected row (wherever that row may be) and place a blank row above it without the contents of the selected row. Can anyone here show me how to do this?
Thanks in advance for any help
Gene
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi genestoy,

It is easy enough to have vba insert a row wherever, you would like it to. Out of curiosity, what are you going to do with copied contents of the selected row. Or have you just mis-phrased the question. Additionally, how do you plan to trigger the macro that inserts a row above your selected row.

igold
 
Upvote 0
I have a row that is shaded (in three places on the worksheet) that is also colored and has the letters A, B & C respectively for the three different sections. The rows beneath these three rows are formatted differently with several columns and filled with data. When I need to insert a new row beneath any of these three rows it always inserts the colored row which is not the one I want inserted but the one with the data and then the cells need to end up blank to accept new data. The rest of the rows are fine with the standard Excel "Insert Sheet Rows".
I would like to just use a keyboard shortcut to insert the formatted blank row anywhere in the worksheet, including the top one under the three sections. Hope that makes sense.
Gene
 
Last edited:
Upvote 0
Got it - in case anybody else needs it, inserts a new blank row above the row that is selected/highlighted with the same formatting intact

Code:
Sub InsertRowAbove()
    ActiveCell.EntireRow.Select
    Selection.Copy
    Selection.Insert Shift:=xlUp
    Application.CutCopyMode = False
    Selection.ClearContents
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,886
Messages
6,168,837
Members
452,220
Latest member
noithatanthien

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