+ Reply to Thread
Results 1 to 8 of 8

Auto Generate ID in Excel

  1. #1
    Registered User
    Join Date
    03-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    8

    Auto Generate ID in Excel

    Hi,

    I have an Excel where in Column B, I populate the an id like DG0001, DG0002...

    First - I need to check for the existing records if the DG number is not assigned then the new DG number need to be assigned depending on the latest/maximum number
    Now going forward, when an new row is added, the id needs to pick up the last DG number and increment it by 1 and assign an new id to that row. I am new to macros and would need the entire code. Please help.

    Thanks!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Auto Generate ID in Excel

    hello,

    I've just created following code for You. I'm sorry without comments
    Please Login or Register  to view this content.
    In attached file You will find working examle (code in Module1)
    Attached Files Attached Files
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  3. #3
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Auto Generate ID in Excel

    Another way.

    Go to Office button ->Prepare -> Properties -> add 541 to the Author field.

    This way, if the count gets off, you can easily go back and fix it.

    Each time you run this macro, it grabs the value in author, adds one to it, searches for it, and the puts it in next row.

    I could add some auto-increment if you like, but since the records are disorganized and random, I think human intervention is warranted.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Tinbendr; 09-05-2012 at 04:14 PM. Reason: Added code for all.
    David
    (*) Reputation points appreciated.

  4. #4
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Auto Generate ID in Excel

    @Tinbendr
    but max value of ID is "DG0615" before I tested your code

  5. #5
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Auto Generate ID in Excel

    Yeah, whatever the 'last record number' is. (Remember, I said human intervention.

  6. #6
    Registered User
    Join Date
    03-16-2011
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Auto Generate ID in Excel

    Hi Tinbendr - Actually it would be great if you can add the auto-incement depending on when data to the new row is added, instead of pressing the "Press Me!" button that MaczaQ has give. Also, for the already existing rows, could an id be populated when we open the excel?

    Thanks for you help!!

  7. #7
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Auto Generate ID in Excel

    Sorry for the delay. Been sick, then, playing catchup.
    Quote Originally Posted by swadson View Post
    Hi Tinbendr - Actually it would be great if you can add the auto-incement depending on when data to the new row is added,
    Because there are trailing rows after the ID number, I feel that automatically auto-incrementing will be difficult to manage.

    instead of pressing the "Press Me!" button that MaczaQ has give.
    You could move the button to the ribbon.

    Also, for the already existing rows, could an id be populated when we open the excel?
    I don't understand this.

    Thanks for you help!!

  8. #8
    Registered User
    Join Date
    09-14-2016
    Location
    Lago Vista, TX
    MS-Off Ver
    Windows 10
    Posts
    1

    Re: Auto Generate ID in Excel

    This code worked well for me as an add new row and populating one cell with an auto ID number when my data is not filtered

    However, I found a problem.... When my data is filtered on the sheet and I attempt to add new, it is populating data (all cells) from an existing entry....it doesn't seem to be a duplicate of that data either. so its changing the existing data ID number to new.. any clues to fix this? filtering by a location then adding a new row is required for my users....

    thanks so much for this service!!

    Cathy

+ 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