Copying and inserting lines

  • Thread starter Thread starter teo410
  • Start date Start date
T

teo410

In my spreadsheet, I was wondering if I could set a macro to copy an entire
row, ask me how many copies of the line I would like to make, and paste them
underneath the original line. Any help would be greatly appriciated!
 
More info but a macro using inputbox, find etc

Sub copyrows()'use FIND to find the row
numrows = InputBox("Number of rows") + 1
Rows(ActiveCell.Row).Copy ActiveCell.Resize(numrows)

End Sub
 
Click on any cell in the row and run:

Sub RowMaker()
Dim r As Range, n As Long, nxtrow As Long, r2 As Range
Set r = ActiveCell.EntireRow
nxtrow = r.Row + 1
n = Application.InputBox(prompt:="How many rows", Type:=1)
Set r2 = Range("A" & nxtrow & ":A" & nxtrow + n - 1)
r.Copy r2
End Sub
 
This is great but I need to INSERT not PASTE the rows in otherwise it pastes
over other information.
 
Sub copyrows()
numrows = InputBox("Number of rows")
'Rows(ActiveCell.Row).Copy ActiveCell.Resize(numrows)
Rows(ActiveCell.Row).Copy
ActiveCell.Resize(numrows).Insert
Application.CutCopyMode = False
End Sub
 
Works great thanks!

Just an additional thought, how could I get the macro to put a border at the
bottom of the last row inserted up to column N?
 
Sub copyrows()
numrows = InputBox("Number of rows")
'Rows(ActiveCell.Row).Copy ActiveCell.Resize(numrows)
Rows(ActiveCell.Row).Copy
ActiveCell.Resize(numrows).Insert
Application.CutCopyMode = False
Range(Cells(ActiveCell.Row, "a"), _
Cells(ActiveCell.Row + numrows, "n")) _
..BorderAround Weight:=xlThick
End Sub
 
Back
Top