+ Reply to Thread
Results 1 to 10 of 10

unique-string generator

  1. #1
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Question unique-string generator

    Hi,

    I was wondering if any of you has already created a unique-string generator
    it cannot be just using date & time as it needs to work during run-time

    I figured out that I can just increment an integer, but I was wondering if any of you has code to do the same in alphanumeric fashion (or just letters, for that matter), to get a shorter id

    .. X,Y,Z,AA,AB,AC ... AZ, BA, BB, ... , ZZ, AAA, AAB, ... etc

    i want to use them in shape names and so on, so the shorter the better

    thanks!

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: unique-string generator

    If Alpha numeric is good, then why not increment A1? It wont change the Letter A but will give you Alpha numeric unique strings..
    Cheers!
    Deep Dave

  3. #3
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: unique-string generator

    Quote Originally Posted by bagullo View Post
    it cannot be just using date & time as it needs to work during run-time
    Can you elaborate more on this? What is the problem using time-stamp
    On the other hand if it's shape names, it could be useful just to start with same common letters and then increment index number...
    If you are pleased with a member's answer then use the Star icon to rate it.

  4. #4
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: unique-string generator

    Quote Originally Posted by buran View Post
    Can you elaborate more on this? What is the problem using time-stamp
    On the other hand if it's shape names, it could be useful just to start with same common letters and then increment index number...
    Hi Buran,
    then thing is that if I write two rows on run-time, 2 of them may be written in the same second, and thus ID is not unique anymore.
    Regarding letters + number, it's one of the ways I am doing it already, I was just wondering about an elegant-looking piece of code to convert strings to number and vice-versa to increment them, in the same way of columns names in excel. (.. AZ, BA, BB, ... )

    Quote Originally Posted by NeedForExcel View Post
    If Alpha numeric is good, then why not increment A1? It wont change the Letter A but will give you Alpha numeric unique strings..
    what do you mean ? incement cell A1? or rather combine letter plus number as buran suggests?

    Thanks!
    Last edited by bagullo; 04-14-2015 at 07:27 AM. Reason: double quoted the same message

  5. #5
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: unique-string generator

    I see, I would definitely go for some common string + index number e.g. shp1, shp2, etc.
    Depending on what you are doing it may turn out to be useful to loop trough all shapes (somewhere in the code) and just check what its name starts with and do something

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: unique-string generator

    what do you mean ? incement cell A1? or rather combine letter plus number as buran suggests?
    Yes Exactly! You can do that..

  7. #7
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: unique-string generator

    If you mean to increment from cell A1, then here's an example:
    Please Login or Register  to view this content.
    debug.print shown in the Immidiate window (Alt+G)

  8. #8
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: unique-string generator

    I am saying something like this. (Berlan's Code Edited)

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Re: unique-string generator

    thanks berlan & Needforexcel

  10. #10
    Forum Contributor
    Join Date
    09-30-2009
    Location
    Barcelona
    MS-Off Ver
    Excel 2010
    Posts
    274

    Smile Re: unique-string generator

    Well --

    finally I did myself the piece of code I whished for. Not quite elegent, but it certainly does work.
    i did it to work just with letters, but changing 26 for whatever number you want, and modifying the mapping funcions it can work as a hexadecimal conversor or change the base to whatever suits you

    Please Login or Register  to view this content.


    numbersToLetter.xlsm

+ 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. Need help removing all symbols from a random string generator...
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2013, 03:48 PM
  2. [SOLVED] Use this unique ID generator macro to insert into a textbox in a userform
    By bg_enigma1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2012, 12:21 PM
  3. Unique Random Number generator
    By David Obeid in forum Excel General
    Replies: 3
    Last Post: 01-28-2008, 11:27 PM
  4. Count unique characters in a string
    By yelkus in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-25-2007, 11:46 AM
  5. Unique Password Generator
    By AllanWilliams in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2007, 11:41 AM

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