Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sb sb is offline
external usenet poster
 
Posts: 16
Default Duplicate rows a given number of times in Excel?

I have a speard sheet that I recieved from a client for some vouchers we are
sending out to some of thier retail locations. It looks like this:

# of vouchers, dollar value, shipping address
5 100 123 street
30 50 456 ave
etc....

There a thousands of row and they need to be submitted as a batch file in
our system, however the batch system needs each voucher to be it's own row,
it cant read the "# of vouchers" and create that many, so for example the
first row is 5 vouchers it needs the dollar amount and address to be
displayed 5 times in seprate rows. How do I make excel look at the first
cell of each row and duplicate the row the number given in the fisrt cell?
I need excel to also recognize it has duplicated the row X number of times
and not to duplicate the duplicates.

Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Duplicate rows a given number of times in Excel?

Sub CreateBatchList()
Dim cnt As Long
Dim cnt2 As Long
For cnt = Range("A" & Rows.Count).End(xlUp).Row to 2 Step -1
'Assumes Header Row
For cnt 2 = 1 to Range("A" & cnt) - 1
Range("A" & cnt) = 1
Rows(cnt).Copy
Rows(cnt + 1).Insert Shift:=xlDown
Next
Next
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


"SB" wrote:

I have a speard sheet that I recieved from a client for some vouchers we are
sending out to some of thier retail locations. It looks like this:

# of vouchers, dollar value, shipping address
5 100 123 street
30 50 456 ave
etc....

There a thousands of row and they need to be submitted as a batch file in
our system, however the batch system needs each voucher to be it's own row,
it cant read the "# of vouchers" and create that many, so for example the
first row is 5 vouchers it needs the dollar amount and address to be
displayed 5 times in seprate rows. How do I make excel look at the first
cell of each row and duplicate the row the number given in the fisrt cell?
I need excel to also recognize it has duplicated the row X number of times
and not to duplicate the duplicates.

Thanks,

  #3   Report Post  
Posted to microsoft.public.excel.programming
sb sb is offline
external usenet poster
 
Posts: 16
Default Duplicate rows a given number of times in Excel?

Thanks Charles, that did exactly what I was looking for, you just saved me a
hours of tedious work. Thank you so much!




"Charles Chickering" wrote:

Sub CreateBatchList()
Dim cnt As Long
Dim cnt2 As Long
For cnt = Range("A" & Rows.Count).End(xlUp).Row to 2 Step -1
'Assumes Header Row
For cnt 2 = 1 to Range("A" & cnt) - 1
Range("A" & cnt) = 1
Rows(cnt).Copy
Rows(cnt + 1).Insert Shift:=xlDown
Next
Next
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


"SB" wrote:

I have a speard sheet that I recieved from a client for some vouchers we are
sending out to some of thier retail locations. It looks like this:

# of vouchers, dollar value, shipping address
5 100 123 street
30 50 456 ave
etc....

There a thousands of row and they need to be submitted as a batch file in
our system, however the batch system needs each voucher to be it's own row,
it cant read the "# of vouchers" and create that many, so for example the
first row is 5 vouchers it needs the dollar amount and address to be
displayed 5 times in seprate rows. How do I make excel look at the first
cell of each row and duplicate the row the number given in the fisrt cell?
I need excel to also recognize it has duplicated the row X number of times
and not to duplicate the duplicates.

Thanks,

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Duplicate rows a given number of times in Excel?

Hi Charles,

This has worked a treat, Could you explain how it works as I'm new to
creating macro. I wish to see if I can edit it so I can have it as a user
input for the number of times to be duplicated as aposed to the data cell #1?

Cheers
--
Paul Wilson


"Charles Chickering" wrote:

Sub CreateBatchList()
Dim cnt As Long
Dim cnt2 As Long
For cnt = Range("A" & Rows.Count).End(xlUp).Row to 2 Step -1
'Assumes Header Row
For cnt 2 = 1 to Range("A" & cnt) - 1
Range("A" & cnt) = 1
Rows(cnt).Copy
Rows(cnt + 1).Insert Shift:=xlDown
Next
Next
End Sub
--
Charles Chickering

"A good example is twice the value of good advice."


"SB" wrote:

I have a speard sheet that I recieved from a client for some vouchers we are
sending out to some of thier retail locations. It looks like this:

# of vouchers, dollar value, shipping address
5 100 123 street
30 50 456 ave
etc....

There a thousands of row and they need to be submitted as a batch file in
our system, however the batch system needs each voucher to be it's own row,
it cant read the "# of vouchers" and create that many, so for example the
first row is 5 vouchers it needs the dollar amount and address to be
displayed 5 times in seprate rows. How do I make excel look at the first
cell of each row and duplicate the row the number given in the fisrt cell?
I need excel to also recognize it has duplicated the row X number of times
and not to duplicate the duplicates.

Thanks,

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
HOW DO I DUPLICATE ONE SHEET MULTIPLE TIMES LC Excel Discussion (Misc queries) 3 June 3rd 10 11:31 PM
How to Autonumber Rows but Retain Same Number for Duplicate Entrie Caledoniain Excel Discussion (Misc queries) 5 January 23rd 09 12:36 PM
Return Time for Duplicate Files & Times Mayte Excel Worksheet Functions 4 May 5th 08 03:30 PM
Duplicate entry "x" number of times gennario Excel Discussion (Misc queries) 1 April 7th 06 11:57 PM
How do I duplicate a sheet 20 times in an excel spreadsheet danzil Excel Worksheet Functions 4 December 17th 04 09:23 PM


All times are GMT +1. The time now is 04:46 PM.

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

About Us

"It's about Microsoft Excel"