+ Reply to Thread
Results 1 to 10 of 10

I have a workbook that I need to auto generate a unique daily 6 digit key number at the pr

  1. #1
    Registered User
    Join Date
    11-07-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    28

    I have a workbook that I need to auto generate a unique daily 6 digit key number at the pr

    Hello,
    I need a bit of help please.
    I have a workbook that I need to auto generate a unique daily 6 digit key number at the press of [Ctrl + C] and insert it into cell C:2 on a sheet called [Day].
    I need a code that while working on [sheet Day] and [Ctrl + C] is pressed the code will look at another sheet [Keys] and the entire column [A] check all previously listed six digit key entry’s (this could be thousands of previous entry’s) and insert a new randomly chosen unique 6 digit key into [sheet Day cell C:2] that has never been used before and is not already listed on [sheet Keys column A] .
    So no duplicates allowed.
    I know that eventually all the six digit combinations will be exhausted, so when this point is reached I will clear column A and start fresh.

    Thank you for your help in advance on this matter and taking the time to read this.

    harry h.

    (The time is fast approaching for all to know his name)

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Hi,

    Is there some meaning to each of the digits in the 6 digit number? If not why not just pick the largest existing 6 digit number and add 1 to it each time you need to generate a new number?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-07-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Thanks for looking Richard,

    I can't do it this way as the six digits are codes for a combination safe and if I where to use your suggestion it could be open to foul play.
    So I need the six digits to be completely randomly chosen.
    Thanks for looking.
    harry h.

    (soon will know of the one and only true God who's name is Jehovah)

  4. #4
    Valued Forum Contributor
    Join Date
    11-02-2012
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    564

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Please Login or Register  to view this content.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Hi,

    On the Keys sheet name a spare cell "Test". In this cell enter the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    adjust the 100000 row as necessary.

    Then add the following macro
    Please Login or Register  to view this content.
    You can't use Ctrl-C since this is reserved for the Copy shortcut. Instead assign the macro to another shortcut key, e.g. Ctrl-k
    Last edited by Richard Buttrey; 06-15-2014 at 07:27 AM.

  6. #6
    Registered User
    Join Date
    11-07-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    I am unable to get any of these suggestions running.

    Maybe I haven't explained it clear enough so here go's. I have changed the sheet names so not to confuse me later.

    I have a work book [Sheet Game]that has a button on it called [change code] when I press it it puts a six digit code into [C2] on this sheet.
    I have another sheet called [Records] that has a long list of previously entered six digit codes in [column A] starting in cell A8 down to a possible 1000000 that are placed here each time a new code is generated from the Game sheet.

    What I need is when I press the button called [Change code] the macro will look at sheet [Records column A] however long it might be and insert a unique six digit number into [C2] on [sheet Game] that is not already listed in [Records column A].

    I hope this is a bit clearer. I can post my code or send a helper a copy of my work book if it will help any.

    Thank you for the help so far.
    harry h.

    (All will soon have to know his name)

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Hi,

    No, you explained it clearly enough, maybe you didn't implement the suggestions correctly.

    I'm attaching a workbook which as far as I understand your requirement gives you what you want. It contains the same stuff that i mentioned in post #5
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    11-07-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Thank you Richard,

    Yes it works here perfectly. I will now place it into my worksheet and try it.
    I will let you know the results.

    harry h.

  9. #9
    Registered User
    Join Date
    11-07-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Hello Richard,

    When I place the code you sent into my work book I get a:
    [Run-time error`1004'
    Method'Range' of object'_Global'failed

    But I still need it to only change the code in [C2 sheet Game]
    I have another button that updates the codes into [column A sheet Records] it just tags the next guessed code in the next available cell in [column A sheet Records]

    harry h.

  10. #10
    Registered User
    Join Date
    11-07-2013
    Location
    Norwich
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: I have a workbook that I need to auto generate a unique daily 6 digit key number at th

    Hello Richard,

    All sorted it was my fault I forgot to name the cell [Test] and I took out the last line of code starting with 'Sheets("Records").Range

    It works great now.
    Thanks very much for all your help and patience.

    harry h.

    (All will come to know his name who is Jehovah)

+ 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. Replies: 22
    Last Post: 06-27-2024, 10:35 AM
  2. Replies: 3
    Last Post: 01-28-2016, 10:02 AM
  3. Macro to generate auto daily files with todays Birthday
    By dingdang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-30-2013, 11:34 PM
  4. Macro to generate a unique number on a shared workbook.
    By adil.master in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2013, 04:22 PM
  5. How to Auto-Generate a duplicate tab on a daily basis
    By jpv5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2012, 03:40 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