Macro for inserting blank row

acaPAWN7

Board Regular
Joined
Oct 11, 2006
Messages
71
I want to create a button that has a function of adding a new blank row below the highlighted row. This might used some macro codes, but I couldn't find any of them. The new blank row will be as the same size with the highlighted row above. And, the new row will be added below of the highlighted row. Hope any expert can develop the codes. Thanks :)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
btw, thanks guys for ur help.. for the code:

Code:
Sub myRow()
Rows(ActiveCell.Row + 1).Insert
End Sub

how can I add the same formula of the active cell (selected rows) to the new added row below? could it be possible? thanks guys, I'm very much appreciated..
 
Upvote 0
Depending on what you mean by "same formula of the active cell" maybe this for all formulas in active row.



Sub RowInsert()
With Application
.ScreenUpdating = False
Dim myRow&
myRow = ActiveCell.Row
Rows(myRow + 1).Insert
Rows(myRow).Copy
Rows(myRow + 1).PasteSpecial Paste:=xlPasteFormulas
.CutCopyMode = False
.ScreenUpdating = True
End With
End Sub
 
Upvote 0
Selection.Offset(1, 0).EntireRow.Insert
Selection.Copy
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
 
Upvote 0
yup, all formula in the active row.. wow, thanks again to Tom Urtis & Steve059L for the solution.. Salute ya~
 
Upvote 0
updating formula

the previous code really helps me in inserting new row under the selected row (along with its formulas too).. Great! But now i'm facing a problem where the SUM formula is not updated after adding the new row.. For example:

Lisa 10
Jack 20
Sarah 10
Willy 5
Total 45


adding a new row (Mark) after Willy..

Lisa 10
Jack 20
Sarah 10
Willy 5
Mark 5
Total 45


but, as we can see the Total is not updated.. it should be 50, not 45.. anyway, is there any need of inserting macro in the TOTAL cell or using certain formula (summation)? hope experts get what i mean here..



for the current, i'm using my own method to update the formula automatically:

adding new row (Mark) between Sarah & Willy..

Lisa 10
Jack 20
Sarah 10
Mark 5
Willy 5
Total 50

now the total is 50.. i wish i wouldn't want to use this method.. hope any experts can solve my problem here.. thanx~
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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