PC Review


Reply
Thread Tools Rate Thread

Copying cell contents a specified number of times 4 mail merge?

 
 
KST8WCT
Guest
Posts: n/a
 
      27th Aug 2009
I have a list of part numbers and quantities that need to be printed on
labels each day. The list will have between 20 and 250 part numbers and
different quantities each day.

part qty
1x 5
2t 23
3b 7

How do I tell Excel to take the part number and paste it the number of times
associated with the quantity for that record into another worksheet and then
repeat until all the records have been processed? This worksheet with the
list will be the data source for a mail merge to print the labels.


 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      27th Aug 2009
Does this code do what you want (change the appropriate assignments to match
your actual layout)...

Sub MakeMailMerge()
Dim X As Long, Z As Long, Qty As Long, Rw As Long
Dim StartRow As Long, LastRow As Long
Dim Source As String, Destination As String
StartRow = 2
Source = "Sheet3"
Destination = "Sheet5"
With Worksheets(Source)
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = StartRow To LastRow
Qty = .Cells(X, "B").Value
For Z = 1 To Qty
Rw = Rw + 1
Worksheets(Destination).Cells(Rw, "A").Value = .Cells(X, "A").Value
Next
Next
End With
End Sub

--
Rick (MVP - Excel)


"KST8WCT" <(E-Mail Removed)> wrote in message
news:6A3B7549-B1C1-43D5-9E0A-(E-Mail Removed)...
>I have a list of part numbers and quantities that need to be printed on
> labels each day. The list will have between 20 and 250 part numbers and
> different quantities each day.
>
> part qty
> 1x 5
> 2t 23
> 3b 7
>
> How do I tell Excel to take the part number and paste it the number of
> times
> associated with the quantity for that record into another worksheet and
> then
> repeat until all the records have been processed? This worksheet with the
> list will be the data source for a mail merge to print the labels.
>
>


 
Reply With Quote
 
KST8WCT
Guest
Posts: n/a
 
      27th Aug 2009
Thank you, Rick. This worked perfectly!

"Rick Rothstein" wrote:

> Does this code do what you want (change the appropriate assignments to match
> your actual layout)...
>
> Sub MakeMailMerge()
> Dim X As Long, Z As Long, Qty As Long, Rw As Long
> Dim StartRow As Long, LastRow As Long
> Dim Source As String, Destination As String
> StartRow = 2
> Source = "Sheet3"
> Destination = "Sheet5"
> With Worksheets(Source)
> LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
> For X = StartRow To LastRow
> Qty = .Cells(X, "B").Value
> For Z = 1 To Qty
> Rw = Rw + 1
> Worksheets(Destination).Cells(Rw, "A").Value = .Cells(X, "A").Value
> Next
> Next
> End With
> End Sub
>
> --
> Rick (MVP - Excel)
>
>
> "KST8WCT" <(E-Mail Removed)> wrote in message
> news:6A3B7549-B1C1-43D5-9E0A-(E-Mail Removed)...
> >I have a list of part numbers and quantities that need to be printed on
> > labels each day. The list will have between 20 and 250 part numbers and
> > different quantities each day.
> >
> > part qty
> > 1x 5
> > 2t 23
> > 3b 7
> >
> > How do I tell Excel to take the part number and paste it the number of
> > times
> > associated with the quantity for that record into another worksheet and
> > then
> > repeat until all the records have been processed? This worksheet with the
> > list will be the data source for a mail merge to print the labels.
> >
> >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to place the cell contents separated by a comma byinserting a new line and then copying the contents anshu minocha Microsoft Excel Programming 1 29th Jan 2010 11:51 PM
Is there a way to place the cell contents separated by a comma byinserting a new line and then copying the contents anshu minocha Microsoft Excel Programming 0 26th Jan 2010 07:29 PM
Format Cell using letter & number to use in mail merge audrey87 Microsoft Excel Worksheet Functions 2 9th May 2009 03:12 PM
need to expand an Excel cell for mail merge contents to show Mrs_Oz Microsoft Excel Setup 1 18th May 2008 06:28 AM
Retain cell number formatting in Word Mail Merge chriskxp2123 Microsoft Excel Programming 0 16th Aug 2005 08:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:45 AM.