Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying cell contents a specified number of times 4 mail merge?

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Copying cell contents a specified number of times 4 mail merge?

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying cell contents a specified number of times 4 mail merge

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" wrote in message
...
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
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
Format Cell using letter & number to use in mail merge audrey87 Excel Worksheet Functions 1 May 9th 09 03:12 PM
Jump to Yahoo Mail with Active Cell Contents, and then perform asearch in the Search Mail Box Mike C[_5_] Excel Programming 0 March 15th 09 12:23 AM
I lose my number formatting in the mail merge? Perkgolf Excel Discussion (Misc queries) 12 June 13th 08 07:11 AM
need to expand an Excel cell for mail merge contents to show Mrs_Oz Setting up and Configuration of Excel 1 May 18th 08 06:28 AM
Retain cell number formatting in Word Mail Merge chriskxp2123[_4_] Excel Programming 0 August 16th 05 08:39 PM


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