+ Reply to Thread
Results 1 to 4 of 4

How to generate 750,000 unique random 6 digits alphanumeric numbers without duplicates?

Hybrid View

  1. #1
    Registered User
    Join Date
    09-09-2016
    Location
    malaysia
    MS-Off Ver
    2010
    Posts
    8

    How to generate 750,000 unique random 6 digits alphanumeric numbers without duplicates?

    Hi,

    I want to generate total 750,000 unique random combination of alpha and numeric numbers without duplicates, without using "O", "0", "1", "i".
    The number of digits is 6 (3 number 3 alphabet).
    Random position and combination among this 6 digits.

    Is there anyone here can teach me how to do it?



    Thanks!

  2. #2
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,179

    Re: How to generate 750,000 unique random 6 digits alphanumeric numbers without duplicates

    Try this ...
    Public Sub Random6()
     Dim MyDictionary As Object
     Dim i As Long, j As Long, K As Long, Str As String
     Dim Temp1 As String, Temp2 As String
     Dim Num1 As Integer, Num2 As Integer
     Dim Random As Double
     Dim Arr(1 To 750000, 1 To 1)
     Temp1 = "23456789"
     Temp2 = "ABCDEFGHJKLMNPQRSTUVWXYZ"
     
    Set MyDictionary = CreateObject("Scripting.Dictionary")
        Randomize
        For i = 1 To 750000
    AA:
                Str = ""
                Num1 = 0
                Num2 = 0
                For j = 1 To 6
                    If Num1 < 3 And Num2 < 3 Then
                        Random = Rnd()
                        If Random < 0.5 Then
                            Num1 = Num1 + 1
                            K = Int(Rnd() * 8) + 1
                            Str = Str & Mid(Temp1, K, 1)
                        Else
                            Num2 = Num2 + 1
                            K = Int(Rnd() * 24) + 1
                            Str = Str & Mid(Temp2, K, 1)
                        End If
                    ElseIf Num1 < 3 Then
                        Num1 = Num1 + 1
                        K = Int(Rnd() * 8) + 1
                        Str = Str & Mid(Temp1, K, 1)
                    Else
                        Num2 = Num2 + 1
                        K = Int(Rnd() * 24) + 1
                        Str = Str & Mid(Temp2, K, 1)
                    End If
                Next j
                If Not MyDictionary.Exists(Str) Then
                    MyDictionary.Add Str, ""
                    Arr(i, 1) = Str
                Else
                    GoTo AA
                End If
        Next i
       Range("A2").Resize(750000, 1) = Arr
    End Sub

  3. #3
    Registered User
    Join Date
    09-09-2016
    Location
    malaysia
    MS-Off Ver
    2010
    Posts
    8

    Re: How to generate 750,000 unique random 6 digits alphanumeric numbers without duplicates

    Hi Phuocam,

    Thanks so much!
    Your support really very much appreciated!

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,179

    Re: How to generate 750,000 unique random 6 digits alphanumeric numbers without duplicates

    You're welcome!

+ 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: 14
    Last Post: 09-21-2016, 05:55 AM
  2. Need to generate random numbers with no duplicates
    By mustbe in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-27-2015, 05:32 PM
  3. Generate random Alphanumeric with two letters and three numbers
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2015, 09:19 PM
  4. Replies: 2
    Last Post: 11-06-2014, 05:07 PM
  5. How to generate unique random alphanumeric 32 character codes?
    By JussiR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-21-2014, 06:30 AM
  6. Auto-Generate random set of four numbers without duplicates?
    By adrien23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2011, 06:03 PM
  7. [SOLVED] How to generate sets of random numbers without having duplicates
    By William in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-06-2006, 12:35 AM

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