+ Reply to Thread
Results 1 to 9 of 9

Add an Autonumber to a column, for use as a sequential Purchase Order Number

  1. #1
    Registered User
    Join Date
    10-16-2013
    Location
    Jacksonville, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Add an Autonumber to a column, for use as a sequential Purchase Order Number

    I am a novice to VBA and am not sure how to code this:


    When a new entry is made in the Job# column, a sequential autonumber is generated and placed into the PO Number field. The number format would be 001-0000 (where the first 3 prefix digits are set, and do not change, but the last 4, displaying leading zeros increment from entry to entry).

    EPO2.1.xlsm
    Last edited by oracle741; 10-24-2013 at 04:30 PM.

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Hi oracle741

    Place this Code in the This Workbook Module
    Please Login or Register  to view this content.
    Place this Code in Sheet1 Module (or whatever you named it in the above Code
    Please Login or Register  to view this content.
    See attached.
    Attached Files Attached Files
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Registered User
    Join Date
    10-16-2013
    Location
    Jacksonville, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Hi John,

    the code works well in the workbook EPO2.1 on it's own; very nicely, thanks. I have been also been working on other VBA Subs (with the help of code examples from other users) and when I include your code with the current version, it does not preform its operation. I tried some logical troubleshooting, but can't see where the problem is. I did rename the worksheet Sub, but that should not make a difference, right?

    I also had two questions; first, is there a way to prevent it from crashing if an attempt is made to enter a job number out of sequence (as in skipping a line). I still would not want them to enter that data, but the Sub crashes if it is tried. Second, is there a way to 'call' the number prefix used from another sheet?

    Thanks,
    Ken

    EPO1.1 (build).xlsm

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Hi Ken

    Yes, doing this does make a difference...I'd ask why did you change it...
    I did rename the worksheet Sub, but that should not make a difference
    Yes this can be done in the Code
    an attempt is made to enter a job number out of sequence (as in skipping a line)
    Yes this can be done...where will it be stored?
    is there a way to 'call' the number prefix used from another sheet

  5. #5
    Registered User
    Join Date
    10-16-2013
    Location
    Jacksonville, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Yes, doing this does make a difference...I'd ask why did you change it...
    I changed it from Private Sub Worksheet_Change to Private Sub Worksheet_Enter; I did this because there is another Subroutine named Worksheet_Change.

    Yes this can be done...where will it be stored?
    It would draw from column 1 on sheet 3; columns 2 and 3 would contain the last name and first name. column 1 would also be formatted in a custom number format to display leading zeros.

    I need to develop the list, but haven't been given the names yet. the three digit prefix would be assigned to an individual who has authority to make purchases. That sheet (sheet 3) would be locked and hidden, if that has bearing on the code.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Hi Ken

    Far as I know there is no
    Private Sub Worksheet_Enter
    Modify your ChangeEvent Code such as this
    Please Login or Register  to view this content.
    Dummy up something that simulates this and I'll look at it
    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number
    Yes, doing this does make a difference...I'd ask why did you change it...
    I changed it from Private Sub Worksheet_Change to Private Sub Worksheet_Enter; I did this because there is another Subroutine named Worksheet_Change.


    Yes this can be done...where will it be stored?
    It would draw from column 1 on sheet 3; columns 2 and 3 would contain the last name and first name. column 1 would also be formatted in a custom number format to display leading zeros.

    I need to develop the list, but haven't been given the names yet. the three digit prefix would be assigned to an individual who has authority to make purchases

  7. #7
    Registered User
    Join Date
    10-16-2013
    Location
    Jacksonville, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Thank you John, the code works flawlessly.

    Also, TIL: the Sub line in VBA is not just a name, but is calling the type of Subroutine being used, thank you.

    I attached the Workbook with the dummy sheet3
    Attached Files Attached Files

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    Hi Ken

    I can show you how to use your "User Names" on Sheet 3 on a Local Machine. I suspect you're on a Network and I can't show you how to do that.

    In the attached I've set "John" assigned to Prefix "007" and you can se the results
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Add an Autonumber to a column, for use as a sequential Purchase Order Number

    You're welcome...glad I could help. Thanks for the Rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro Reqd to update Purchase order log, everytime a new purchase order is made
    By manthankanabar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 01:47 AM
  2. Sequential Purchase Order No and File As
    By jujuwillis in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-07-2012, 12:51 PM
  3. purchase order list & order number generator
    By podaf in forum Excel General
    Replies: 2
    Last Post: 06-28-2009, 06:02 PM
  4. Replies: 1
    Last Post: 04-28-2006, 02:20 PM
  5. purchase order counter in excel purchase order template
    By Brandy@baoco in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-23-2005, 03:06 PM

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