Insert New Row

N

Neil Pearce

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
 
S

Stefi

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top