LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,071
Default How to copy Excel records?

The macro below will do that. I assumed that you have headers in row 1 and
your data starts in row 2. This macro loops through all the values in
Column Z and if the value is greater than zero, it inserts that many new
blank rows below that row, and copies the original row (25 columns) to all
the new rows. HTH Otto
Sub CopyRows()
Dim rColZ As Range
Dim c As Long
Set rColZ = Range("Z2", Range("Z" & Rows.Count).End(xlUp))
For c = rColZ.Count To 1 Step -1
If rColZ(c) 0 Then
rColZ(c).Offset(1).Resize(rColZ(c).Value).EntireRo w.Insert
Cells(rColZ(c).Row, 1).Resize(, 25).Copy _
Cells(rColZ(c).Row + 1, 1).Resize(rColZ(c).Value)
End If
Next c
End Sub
"abc" wrote in message
...
Thanks for your reply.

The task is exactly as you described. :-)
After copying the number in column Z won't be neccessary anymore,
so it needn't to be copied.
I need to do it because I use the Excel file in MailMerge process
and I don't know any other method to use a record more than once if
needed.

Are you saying that if Column Z has, say a 3, that you want to copy that
row, say row 10, 3 times and place those 3 copied rows under row 10?
That would make rows 11, 12, and 13, the same as row 10. Is that what
you want? If so, you would need VBA. Post back and clarify what (and
why??) you want to do. HTH Otto


My Excel file has thousends of records and columns let's say
from A to Z.
In column Z there is one of numbers: 0 or 1 or 2 or 3.
The problem is how to copy each record 0 or 1 or 2 or 3 times
and insert the copies under the original.




 
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
Copy records that are 4 rows apart Pablo Excel Discussion (Misc queries) 5 March 27th 08 04:58 PM
Copy specific records from a worksheet to another Irfan Excel Worksheet Functions 3 January 29th 08 05:36 PM
How do I copy records with specific text from one wkbk to another MichaelM Excel Worksheet Functions 0 September 19th 07 08:56 PM
How to copy records containing a specific date range to new sheet? Chrys Excel Worksheet Functions 1 January 30th 06 08:19 PM
Removing all duplicate records except one copy adam a Excel Discussion (Misc queries) 8 August 30th 05 05:53 AM


All times are GMT +1. The time now is 11:14 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"