numbering raffle tickets in word

I want to make a raffle ticket template in word.  I want to print out 4000 tickets, 8 per sheet, making it 500 sheets of paper.  I want them to be numbered down the column of tickets. So, the top left raffle ticket would be number 1, then on the second sheet the top left raffle ticket would be number 2 and so on till the last sheet top left raffle ticket would be number 500.  Then the top right raffle ticket would be number 501 and so on.  The first sheet would have numbers 1,501,1001,1501,2001,2501,3001,3501.
chad201008Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
Does this macro suit you?

Sub CreateRaffleTickets()
    Dim tbl As Table
    Dim doc As Document
    Dim rng As Range
    Dim r As Integer
    Dim t As Integer
    Dim b As Integer
    Dim cl As Cell
   
    Set doc = Documents.Add
    For t = 1 To 500
        r = t
        Set rng = doc.Bookmarks("\EndOfDoc").Range
        Set tbl = doc.Tables.Add(rng, 4, 2)
       
        tbl.AllowAutoFit = False
        tbl.Columns.Width = CentimetersToPoints(6)
        tbl.Rows.Height = CentimetersToPoints(6)
        For b = -6 To -1
            tbl.Borders(b).LineStyle = wdLineStyleSingle
        Next b
        For Each cl In tbl.Range.Cells
            cl.Range.Text = "Raffle ticket number: " & r
            r = r + 500
        Next cl
        Set rng = doc.Bookmarks("\EndOfDoc").Range
        rng.InsertParagraph
        Set rng = doc.Bookmarks("\EndOfDoc").Range
        rng.InsertBreak wdPageBreak
    Next t
End Sub
0
chad201008Author Commented:
this works great but can you breakdown the macro so that i can tweek it if i need.  thanks!
0
GrahamSkanRetiredCommented:
I've added a few comments

Sub CreateRaffleTickets()
    Dim tbl As Table
    Dim doc As Document
    Dim rng As Range
    Dim r As Integer 'raffle ticket number
    Dim t As Integer 'table/page counter
    Dim b As Integer 'border type
    Dim cl As Cell 'table cell object
   
    Set doc = Documents.Add 'start with a new document
    For t = 1 To 500
        r = t 'first ticket number on page is the same as the page number
        Set rng = doc.Bookmarks("\EndOfDoc").Range' go to the nd of the document
        Set tbl = doc.Tables.Add(rng, 4, 2) 'add a new table
       
        tbl.AllowAutoFit = False 'make sure that the cell cannot expand
        tbl.Columns.Width = CentimetersToPoints(6) 'set the width
        tbl.Rows.Height = CentimetersToPoints(6) 'and height
        For b = -6 To -1 'ensure that the cell and table borders are visible
            tbl.Borders(b).LineStyle = wdLineStyleSingle
        Next b
        For Each cl In tbl.Range.Cells
            cl.Range.Text = "Raffle ticket number: " & r 'Insert text and number in table cell
            r = r + 500 'increment ticket number on this page
        Next cl
        Set rng = doc.Bookmarks("\EndOfDoc").Range
        rng.InsertParagraph 'so that next table is kept separate
        Set rng = doc.Bookmarks("\EndOfDoc").Range
        rng.InsertBreak wdPageBreak 'start new page.
    Next t
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.