ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert New Row (https://www.excelbanter.com/excel-discussion-misc-queries/237785-insert-new-row.html)

Neil Pearce

Insert New Row
 
Good morning,

The following recorded code copies row 1 inserts it at row 10 andthen
selects cell A10.

How would it be adapted such that the user would be prompted as to above
which row they would like to insert the copied row?

e.g. macro copies row 1, prompt user "above which row would you like to
enter the copied row?", copy row to selected place, select cell in column A
of new row.

Sub INSERT_NEW_ROW()
'
' INSERT_NEW_ROW Macro
' Macro recorded 23/07/2009 by Gleeds
'

'
Rows("1:1").Select
Selection.Copy
Rows("10:10").Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Range("A10").Select
End Sub


Your in appreciation,

Neil


Stefi

Insert New Row
 
Try this:

Sub INSERT_NEW_ROW()
'
' INSERT_NEW_ROW Macro
' Macro recorded 23/07/2009 by Gleeds
'

'
Rows("1:1").Select
Selection.Copy
insrow = InputBox("Enter row No you want to insert above!")
insrownum = Val(insrow)
If insrownum = 0 Then
Application.CutCopyMode = False
MsgBox "This is not a number!"
Exit Sub
End If
Rows(insrow).Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Range("A10").Select
End Sub

Regards,
Stefi

€˛Neil Pearce€¯ ezt Ć*rta:

Good morning,

The following recorded code copies row 1 inserts it at row 10 andthen
selects cell A10.

How would it be adapted such that the user would be prompted as to above
which row they would like to insert the copied row?

e.g. macro copies row 1, prompt user "above which row would you like to
enter the copied row?", copy row to selected place, select cell in column A
of new row.

Sub INSERT_NEW_ROW()
'
' INSERT_NEW_ROW Macro
' Macro recorded 23/07/2009 by Gleeds
'

'
Rows("1:1").Select
Selection.Copy
Rows("10:10").Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Range("A10").Select
End Sub


Your in appreciation,

Neil



All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com