+ Reply to Thread
Results 1 to 4 of 4

Auto ID based on Prefix and suffix

  1. #1
    Registered User
    Join Date
    11-07-2014
    Location
    Botswana
    MS-Off Ver
    2007
    Posts
    2

    Auto ID based on Prefix and suffix

    Hello

    sorry, ive read a few posts on Auto ID but i still cant get to do what i want.

    I want to create Auto ID's based on user defined prefix and suffix in excel.
    preferably it should operate like a form, making it quick and easy to generate consecutive ID's.

    eg.
    Prefix-AutoID-Suffix
    ABCD-0000-xx

    The best way to describe its use is as labeling buckets of materials
    The Prefix says what material the bucket is carrying
    Auto ID gives a unique ID (incremental) when more buckets are carrying the same material
    The Suffix gives the quantity in the bucket, which is measured on site.

    Like a form the user only has to define a prefix then input a new suffix to create the next ID.

    I thought it was quite simple, but its turned out much harder than i thought.

    To make it simple, lets say, the user labels all buckets carrying the same material in one go, not changing materials frequently, hence the macro doesn't have to look up what was the last ID used on a particular prefix. It can just increase the Auto ID by 1, given a new quantity. The user then manually changes the prefix for the next (different) material and the count starts again. If the user needs to go back to a material he's already done, he can look up the last ID used manually and start from there.

    Infact it was the thought of the last paragraph that seems to have confused me now. getting rid of the need to look up the last ID seems to have made it harder than easier :-s

    Any input will be much appreciated.

    Thank you

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Auto ID based on Prefix and suffix

    Hi, welcome to the forum

    Not sure you need VBA for this. If your data looks something like this, with your 1st "seed" entry in B1...
    A
    B
    1
    ABCD000110
    2
    ABCD ABCD0002
    3
    ABCD ABCD0003
    4
    ABCD ABCD0004
    5
    ABCD ABCD0005
    6
    ABCD ABCD0006
    7
    ABCD ABCD0007
    8
    ABCD ABCD0008
    9
    ABCD ABCD0009
    10
    ABCD ABCD0010

    B2=A2&TEXT(MID(B1,LEN(A2)+1,4)+1,"0000")
    copied down.

    We could probably work something out for the last xx if needed
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    11-07-2014
    Location
    Botswana
    MS-Off Ver
    2007
    Posts
    2

    Re: Auto ID based on Prefix and suffix

    Hey thanx alot
    Yip that did the trick for the first bit...
    I could use the same function to add the xx at the end, and the user can just manually edit xx to the quantity desired.

    It works, i guess that's what counts.
    Thank you, that was quite simple and effective.

    any hints on how i could further improve it? so one can use just 2 input cells rather than making whole columns for the inputs?

    Thanks again

  4. #4
    Registered User
    Join Date
    12-15-2009
    Location
    USA
    MS-Off Ver
    2003,2007,2010,2013
    Posts
    28

    Re: Auto ID based on Prefix and suffix

    Hi RSK88,

    You asked for hints for improvement. I'd recommend keeping Value fields separate from Key fields. The Material Type and Quantity are Value fields. The Auto-ID is a Key field.

    Why this is important:
    • Scanning: If we ever want to use scanning, each bucket will need a tag. If that tag ONLY contains the Auto-ID it can be used forever.
    • Reporting: If we need to sum the quantity of a Material Type, it will be easier if the Quantity and Material Type are separate
    • Linking: If we need to link Material Type to a Material Master it will be easier if the Material Type is separate
    • Logging: If we need to track each bucket's movements, we only need the unique Auto-ID.
    • Adjusting: If we need to correct a bad value entry, like quantity, we can just change quantity and not invalidate the key and tag and not orphan the record from its logs.
    • Searching: Finding buckets containing a material type and/or minimum quantity is easier if we keep those fields separate.

    For more on the science behind this recommendation see: http://en.wikipedia.org/wiki/Database_normalization

    Best Wishes,

    Craig
    Last edited by CHatmaker; 11-08-2014 at 09:40 AM.

+ 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. Prefix and Suffix Help
    By Scott Holmes in forum Excel General
    Replies: 3
    Last Post: 10-06-2015, 11:58 AM
  2. How to add prefix and suffix to a cell?
    By adi26 in forum Excel General
    Replies: 2
    Last Post: 08-28-2009, 03:21 AM
  3. Add Suffix & Prefix
    By di22y in forum Excel General
    Replies: 1
    Last Post: 06-25-2009, 06:34 PM
  4. adding prefix and suffix macro
    By justix in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 01-10-2007, 06:14 AM
  5. Prefix and Suffix
    By Clare in forum Excel General
    Replies: 2
    Last Post: 01-30-2006, 03:30 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