+ Reply to Thread
Results 1 to 4 of 4

vba to auto increase an ID number

  1. #1
    Forum Contributor
    Join Date
    04-20-2017
    Location
    Iowa
    MS-Off Ver
    2007
    Posts
    212

    vba to auto increase an ID number

    What I want to do is have a textbox or other form control look at a data list and then assign a new ID number automatically.

    For example: the form as selected on the main menu sheet will look at range B:B and then assign the next sequential number CR0002 when a new record is created.

    When the user clicks the New ECR command button on the main menu sheet the ID Number textbox will display the next available number in the sequence without user input.

    I've looked at some rather convoluted methods for this, but I'm betting there is a quite simple method available .

    As always
    Thank you for all input.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: vba to auto increase an ID number

    Hello rob_h,

    Here is the updated UserForm code that has been added to the attached workbook. This examines column "B" on the "ECR List" worksheet for highest ID value and adds 1 to it. If no IDs are on the sheet then "CR0001" is the default.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: vba to auto increase an ID number

    Also better to work from down up when writing values to worksheet.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Contributor
    Join Date
    04-20-2017
    Location
    Iowa
    MS-Off Ver
    2007
    Posts
    212

    Re: vba to auto increase an ID number

    Thank you both for the help, works great.

+ 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] Auto increase quote number
    By supremelighting in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2016, 12:30 PM
  2. [SOLVED] Need to increase/decrease 2 numbers(a whole number and a %) dependent on a goal number
    By brianlross in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 10-19-2015, 02:28 PM
  3. Auto increase number and save as macro
    By SPet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2013, 01:07 PM
  4. Replies: 3
    Last Post: 09-18-2012, 01:01 AM
  5. Replies: 0
    Last Post: 01-10-2012, 03:48 PM
  6. Auto increase cell reference
    By GRAMMY in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2011, 02:13 AM
  7. Auto increase # based on other cell
    By tstanard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2007, 06:19 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