[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4140
  • Last Modified:

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.
0
chad201008
Asked:
chad201008
  • 2
1 Solution
 
GrahamSkanCommented:
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
 
GrahamSkanCommented:
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now