+ Reply to Thread
Results 1 to 5 of 5

Creating a "ticket number" with VBA

  1. #1
    Registered User
    Join Date
    05-23-2011
    Location
    Lincoln, NE
    MS-Off Ver
    Excel 2007
    Posts
    30

    Creating a "ticket number" with VBA

    New to VBA and this forum.

    I am creating a userform to allow multiple users to fill out an excel spreadsheet to track IT-related issues. Each record gets a unique "ticket number" which is made up of the date in yyyymmdd format plus a letter (these tickets are currently created by a single user who manually assigns the ticket number using this numbering scheme). The first "ticket" created on a given day is assigned the letter 'A' (20110523A), the second is assigned letter 'B' (20110523B) and so on. The first ticket tomorrow would be 20110524A and so on.

    Since each user may be submitting a ticket independent of each other, I would like to automate the ticket numbering process so that excel will create the ticket number when the ticket is submitted. Ideally, after the ticket is submitted, a message box would pop up that says something like "The ticket number assigned to this issue is '20110523B'." The date portion of the ticket number seems easy enough but is there a way to have excel look at existing records and determine what letter should be assigned to the ticket?

    Can someone help me with the VBA code needed?

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Creating a "ticket number" with VBA

    Rather than search over existing records, which could be long and complicated, why not store the ticket number and date on two unused cells. It could even be on a workbook that would remain hidden forever. The code would then look something like this:

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Creating a "ticket number" with VBA

    Here is what i came up with. I used a command button to generate the ticket number.

    I assumed that the ticket numbers are stored in column A. This can be edited by changing the myRange line.

    Please Login or Register  to view this content.
    Last edited by stnkynts; 05-23-2011 at 04:25 PM. Reason: added datavalidation for possible empty column

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Creating a "ticket number" with VBA

    Wanted to change it just a little bit. If you want to see how it works just run the code on a blank worksheet.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-27-2014
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Creating a "ticket number" with VBA

    Hi Stnkynts,
    I tried your code below and it works. However, anytime two users log in at the same time, both get the same ticket number. Please how can i resolve this issue.



    Quote Originally Posted by stnkynts View Post
    Here is what i came up with. I used a command button to generate the ticket number.

    I assumed that the ticket numbers are stored in column A. This can be edited by changing the myRange line.

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1