+ Reply to Thread
Results 1 to 8 of 8

Automatically generate order number and increment by 1 and post into worksheet.

  1. #1
    Registered User
    Join Date
    01-21-2015
    Location
    Altrincham, England
    MS-Off Ver
    2010
    Posts
    6

    Automatically generate order number and increment by 1 and post into worksheet.

    Hi All,

    I have created a userform which allows a user to fill in set fields which posts the data entered into the relevant cells in a worksheet in a separate workbook.

    I am quite new at VBA coding and am struggling to find the relevant sources to help me create an order number that is automatically generated.

    My desired result is that once all fields have been completed the user clicks a button and the following happens:
    • Opens workbook and posts the data into the sheet
    • Check the last order number and increment it by 1
    • Add the new order number in the relevant cell in the relevant row with all other data
    • Save workbook
    • close workbook
    • Quote order number in message box

    I want all order numbers to start with "ATH -" then start "000000" and increment by 1 "000001, 0000002 and so on"

    My worksheet currently looks like:

    worksheet.png

    And my VBA code is:

    HTML Code: 

  2. #2
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    Hi,
    Please replace this.
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.
    If your question is resolved, mark it SOLVED using the thread tools. Click on the star if you think some-1 helped you.
    Last edited by LokeshKumar; 04-17-2015 at 05:04 AM.
    Lokesh Kumar
    Stay Hungry.. Stay Foolish..
    _________________________________________________________
    Please Click STAR to Add Reputation if my/someone's answer helped!

  3. #3
    Registered User
    Join Date
    01-21-2015
    Location
    Altrincham, England
    MS-Off Ver
    2010
    Posts
    6

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    Hi LokeshKumar,

    Thank you for your quick reply!

    How would you quote that number in a msg box after it has saved the data to the worksheet and form has been unloaded?

    Thank you

  4. #4
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    could you post the workbook and exactly what you want ..........

  5. #5
    Registered User
    Join Date
    01-21-2015
    Location
    Altrincham, England
    MS-Off Ver
    2010
    Posts
    6

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    Hi,

    I have two workbooks, one with the userform on it and the second to log all the data submitted by the userform (this is so multiple people can use the userform).

    I want each userform entry to have a unique reference number in the format I advised (ATH000001 etc). I want the macro to check the last reference quoted and then increment it by 1.

    Once the user has filled in all the details on the userform they click a "generate" button which the macro should then generate a new reference number, log that reference along with all other data entered into the userform and then quote that reference number in a message box. Then clear and unload the form for the next user.

    Based on the code I had and the snippet you provided I have the form to do everything I have described but actually quote the number at the end.

    I hope this makes sense

    I have attached the two workbooks.
    Attached Files Attached Files

  6. #6
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    Hi,
    Please see the below my comments after ''''''''''''''''''''''''''

    Please Login or Register  to view this content.


    If your question is resolved, mark it SOLVED using the thread tools. Click on the star if you think some-1 helped you.

  7. #7
    Registered User
    Join Date
    01-21-2015
    Location
    Altrincham, England
    MS-Off Ver
    2010
    Posts
    6

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    Hi LokeshKumar,

    Thank you again for your reply.

    The OrderNumber is a text field that the user manually enters this is (emptyRow, 7) in the code. The Authorisation number that I want to automatically generate, save a quote doesn't have a text field on the userform because it's not something the user enters.

    The code you have provided seems to target the OrderNumber text field, not the Authorisaton number that gets generated and inputted in (emptyRow, 8).

    I get an error "Invalid qualifier" when I use the added code.

    The code you have provided:

    Please Login or Register  to view this content.
    Shouldn't this be inside the Msgbox so it is quoted?

    Thank you for your continued help.

  8. #8
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Automatically generate order number and increment by 1 and post into worksheet.

    Hi,

    As I per your last reply, I have made following changes....hope that work.....

    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)

Similar Threads

  1. [SOLVED] Purchase Order Printing (Automatically increment the number in a cell)
    By bigsi1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2013, 03:37 AM
  2. increment order number
    By mathewtaylor in forum Excel General
    Replies: 2
    Last Post: 03-25-2007, 04:18 PM
  3. [SOLVED] Increment Purchase Order Number
    By Curious in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2006, 09:40 AM
  4. Generate auto increment number from VB form
    By john_t_h in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2005, 06:19 PM
  5. [SOLVED] How do I automatically increment worksheet number when pasting a .
    By Mr Keldor in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-21-2005, 02:06 PM

Tags for this Thread

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