View Single Post
  #2   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default User keys in serial number range, labels auto-fill

Start with a document containing one page of empty labels (labels in Word
are just table cells with fixed dimensions) and then run a macro containing
the following code:

Dim i As Long, j As Long, n As Long, m As Long
Dim labeltext As String
Dim startnum As Long
Dim endnum As Long
Dim labels As Long
Dim newrow As Row
labeltext = InputBox("Enter the text for the label")
startnum = InputBox("Enter the starting number")
endnum = InputBox("Enter the last number")
labels = InputBox("Enter the number of labels in a row")
n = 0
With ActiveDocument.Tables(1)
For m = .Rows.Count To 2 Step -1
.Rows(m).Delete
Next m
For i = 1 To (endnum - startnum + 1) / labels
Set newrow = .Rows.Add
With newrow
For j = 1 To labels
.Cells(j).Range.Text = labeltext & Format(startnum + n,
"0000")
n = n + 1
Next j
End With
Next i
.Rows(1).Delete
End With

It will first ask for the text part of the label (RED), then the first
number to use 1 and the last number to use 1001 and the number of labels on
each row.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"buscher75" wrote in message
...
I would like create a user friendly word document that promts the user to
enter in the serial number range ex: RED0001 - RED1001 and have the labels
automatically fill in as many sheets as needed. I am converting these
numbers into a barcode.
I do not know a lot about this so details would be wonderful. Any ideas
on
how to do this would be greatly appreciated. Thank You.