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 :)
 

Some videos you may like

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

acaPAWN7

Board Regular
Joined
Oct 11, 2006
Messages
71
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..
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,208

ADVERTISEMENT

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
 

SteveO59L

Well-known Member
Joined
Apr 21, 2004
Messages
7,896
Selection.Offset(1, 0).EntireRow.Insert
Selection.Copy
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
 

acaPAWN7

Board Regular
Joined
Oct 11, 2006
Messages
71
yup, all formula in the active row.. wow, thanks again to Tom Urtis & Steve059L for the solution.. Salute ya~
 

acaPAWN7

Board Regular
Joined
Oct 11, 2006
Messages
71
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~
 

Watch MrExcel Video

Forum statistics

Threads
1,113,811
Messages
5,544,448
Members
410,611
Latest member
JB_101920
Top