Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
hugo901 hugo901 is offline
external usenet poster
 
Posts: 2
Default Multiple labels from one row in the data list based on a variable

How do I get Word to add multiple labels in the merged label file based on a
variable in a cell in the data list? Say the value in the column "Quantity"
of a row is 20. I'd like 40 labels for that row of data. If the value is 1,
I'd like 2 labels.

Thank you,
Hugo
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Multiple labels from one row in the data list based on a variable

What is the data source? Excel? Access table?...

--
Peter Jamieson
http://tips.pjmsn.me.uk

"hugo901" wrote in message
...
How do I get Word to add multiple labels in the merged label file based on
a
variable in a cell in the data list? Say the value in the column
"Quantity"
of a row is 20. I'd like 40 labels for that row of data. If the value is
1,
I'd like 2 labels.

Thank you,
Hugo


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
hugo901 hugo901 is offline
external usenet poster
 
Posts: 2
Default Multiple labels from one row in the data list based on a varia

Excel.

"Peter Jamieson" wrote:

What is the data source? Excel? Access table?...

--
Peter Jamieson
http://tips.pjmsn.me.uk

"hugo901" wrote in message
...
How do I get Word to add multiple labels in the merged label file based on
a
variable in a cell in the data list? Say the value in the column
"Quantity"
of a row is 20. I'd like 40 labels for that row of data. If the value is
1,
I'd like 2 labels.

Thank you,
Hugo



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Multiple labels from one row in the data list based on a varia

One way is to run an Excel macro on a copy of your sheet - someone posted
the code below a while back )(well, actually, this is their version with
oding suggestions by me, such as they are, so not well tested)...

'------------------------------------------------------
Sub RepeatMailingLabels()


' Using constants makes it easier to modify the sheets you want to use
' But there are other ways to parameterise this, for example using workbook
and worksheet names


Const sourceSheet = 1 ' the sheet number containing the source data
Const targetSheet = 2 ' the sheet number that will contain the label data
Const countColumn = 1 ' the column in sourceSheet that contains the label
count


' Let's try to declare every variable we use


Dim c As Integer
Dim r As Long
Dim lDestStartRow As Long
Dim lDestRow As Long


' Let's put "Excel." in front of Excel objects. That way, we have a much
better
' chance of using this code even in Word VBA


Dim wsSource As Excel.Worksheet
Dim wsTarget As Excel.Worksheet
Dim mbrAnswer As VbMsgBoxResult
Dim rng2Copy As Excel.Range
Set wsSource = Excel.ActiveWorkbook.Sheets(sourceSheet)
Set wsTarget = Excel.ActiveWorkbook.Sheets(targetSheet)


If ActiveWorkbook.Sheets.Count 2 Then


' Spell it out! The clearer the better.


MsgBox "Your Workbook must have at least two Sheets. The first sheet is
assumed to be the source of the data, and column one contains the label
count. The second sheet will be overwritten by the results.", vbCritical,
"Sheet Count"
Exit Sub
Else
mbrAnswer = MsgBox("This macro will delete all information on the second
sheet in your workbook: '" & UCase(wsTarget.Name) & "'" & vbCr & vbCr & "Do
you want to proceed?", vbQuestion + vbYesNo, "Run Label Maker")
If mbrAnswer = vbYes Then


' Clear everything in the target worksheet
wsTarget.Cells.Clear
Else
Exit Sub
End If
End If


' Copy the first row


Set rng2Copy = wsSource.Cells(1, 1).CurrentRegion
For c = 1 To rng2Copy.Columns.Count
wsTarget.Cells(1, c) = wsSource.Cells(1, c)
Next c


' set up the starting row in the target


lDestStartRow = 2


' for each row in the source...


For r = 2 To rng2Copy.Rows.Count


....make the number of copies in the target specified in the appropriate
column
For lDestRow = lDestStartRow To lDestStartRow + wsSource.Cells(r,
countColumn) - 1
For c = 1 To rng2Copy.Columns.Count
wsTarget.Cells(lDestRow, c) = wsSource.Cells(r, c)
Next
Next


' remember where to start the next set of copies in the target
lDestStartRow = lDestStartRow + wsSource.Cells(r, countColumn)
Next


' It's good programming practice to release objects that we
' set up


Set wsTarget = Nothing
Set wsSource = Nothing
End Sub

'------------------------------------------------------



--
Peter Jamieson
http://tips.pjmsn.me.uk

"hugo901" wrote in message
...
Excel.

"Peter Jamieson" wrote:

What is the data source? Excel? Access table?...

--
Peter Jamieson
http://tips.pjmsn.me.uk

"hugo901" wrote in message
...
How do I get Word to add multiple labels in the merged label file based
on
a
variable in a cell in the data list? Say the value in the column
"Quantity"
of a row is 20. I'd like 40 labels for that row of data. If the value
is
1,
I'd like 2 labels.

Thank you,
Hugo




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Data Publishing with Word doug thomson Mailmerge 1 May 18th 07 10:55 PM
insert a variable length List BPace Microsoft Word Help 4 October 26th 06 02:56 PM
Variable Use in Multiple Documents Denise Microsoft Word Help 2 February 23rd 06 05:04 PM
how do i make a list of contents based on multiple documents pedorf Microsoft Word Help 2 June 23rd 05 06:49 PM
How do I print multiple labels containing multiple data? Finch Microsoft Word Help 2 June 23rd 05 06:11 AM


All times are GMT +1. The time now is 01:18 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"