Hi I really need help. I need to create as many unique 4 digit codes using numbers 1 to 20 for staff to use. I have been trying various formulas but keep getting duplicates. What should I do?
Hi I really need help. I need to create as many unique 4 digit codes using numbers 1 to 20 for staff to use. I have been trying various formulas but keep getting duplicates. What should I do?
Erm... Can you explain a 4 digit code using numbers 1 to 20??
let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source
If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE
Walking the tightrope between genius and eejit...
Your description is a little confusing because how do you compose 4-digit codes from the numbers 1-20? Do you mean that you have to generate 20 different unique 4-digit codes?
Here is one example. I don't know of a way to do this by formulas alone. This method requires one manual step to refresh the list.
There are three columns. The first column is a sequence number, which you can use to assign PINs to people. This column can be anything you want--names, employee numbers, account numbers. The second column is the PIN associated with that sequence number. There are 1000 unique PINs in this column (there are 1000 unique possible 4-digit PINs). The third column is random numbers. To generate a fresh set of PINs, click on the dropdown at the top of column C and select "Sort smallest to largest." The PINs will be shuffled and reassigned to the sequence numbers.
It is also possible to do this with macros, but this was a little quicker to put together.
Sorry all. It's late and the pressure is getting to me.
Example, using 1 to 20 random but unique limited to 4 numbers
5 9 10 11 12
20 7 14 1 19
Etc. etc.
I bought this call logging system to assign to people when they make an outgoing call and it was cheap so now I have to create and manually enter codes to accept when they use the phone
Must be really late. Your examples have five numbers. Please try again...
Here's a little bit of code, which randomly generates a set of five numbers between 1-20, with no duplicate combinations.
Double click the PIN heading to add a new combination to the list.
Apologies it's 5 digit. Thank you 6Stringjazzer for pointing out
Ollyxls. Thank you for that. I will give it a try at the office today.
Ah, so you don't want duplicates in each set of 5 numbers? That wasn't clear...
Let me have a look at it.
Okay - change the code to:
To change the number range, amend the numbers coloured red.Please Login or Register to view this content.
To change the count of number returned in the overall PIN combination, change the number coloured blue. This loops from 0, not 1, so enter one less than the value you need - so, for 5 x numbers, enter 4 here.
Awesome - works great.
I now did not see any duplicate numbers in each - PERFECT
It works great. Now I noticed that there are many different number sets and I can get just by double clicking the "PIN" - is there a way to run every possible number set for that range? I should then be able to load that CSV file into my systems data base. If it is possible, just to know how many sets i can get till it runs out.
Hi Olly,
Any help with last request?
There's almost 2M permutations -- is there really value in listing them all?
Entia non sunt multiplicanda sine necessitate
Hi Shg, thank you for replying. With that many permutations I surely will be ok for a long time so at this stage no further action required. Appreciate the reply.
Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.
In future, to mark your thread as Solved, you can do the following -
Select Thread Tools-> Mark thread as Solved.
Incase your issue is not solved, you can undo it as follows -
Select Thread Tools-> Mark thread as Unsolved.
Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
If I have helped, Don't forget to add to my reputation (click on the star below the post)
Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Use code tags when posting your VBA code: [code] Your code here [/code]
Thank you for that information.
Appreciate the response and actions going forward
How could we update this macro if we needed this to generate PINs without sequential numbers?
Administrative Note:
Welcome to the forum.
We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.
Please see Forum Rule #4 about hijacking and start a new thread for your query.
If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks