Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Copying and inserting lines

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!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Copying and inserting lines

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teo410" wrote in message
...
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!


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Copying and inserting lines

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

--
Gary''s Student - gsnu200860


"teo410" wrote:

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!

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Copying and inserting lines

This is great but I need to INSERT not PASTE the rows in otherwise it pastes
over other information.

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200860


"teo410" wrote:

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!

  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 14
Default Copying and inserting lines

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?

"Don Guillett" wrote:



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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teo410" wrote in message
...
This is great but I need to INSERT not PASTE the rows in otherwise it
pastes
over other information.

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200860


"teo410" wrote:

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!



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Copying and inserting lines

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teo410" wrote in message
...
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?

"Don Guillett" wrote:



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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"teo410" wrote in message
...
This is great but I need to INSERT not PASTE the rows in otherwise it
pastes
over other information.

"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200860


"teo410" wrote:

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!




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting new lines with corresponding number tripflex Excel Discussion (Misc queries) 1 March 9th 09 03:28 PM
inserting new lines with number tripflex Excel Discussion (Misc queries) 2 March 6th 09 10:10 PM
inserting lines throughout a spreadsheet Kerry Excel Worksheet Functions 3 October 18th 06 11:07 PM
Inserting # of lines from one spreadsheet to another klafert Excel Discussion (Misc queries) 1 August 30th 06 01:18 PM
Inserting Lines or Copying lines with formulas but without data wnfisba Excel Discussion (Misc queries) 2 August 18th 06 04:41 PM


All times are GMT +1. The time now is 09:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"