JumboCactuar
Well-known Member
- Joined
- Nov 16, 2016
- Messages
- 788
- Office Version
- 365
- Platform
- Windows
Hi,
i'm using this code to generate a unique 4 character string, but hours later i'm seeing it generate the same 4 character strings again
Am i doing something wrong?
i'm using this code to generate a unique 4 character string, but hours later i'm seeing it generate the same 4 character strings again
Am i doing something wrong?
VBA Code:
Function GenerateRandomString() As String
Dim i As Integer
Dim strResult As String
Dim strChars As String
strChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
' Initialize the random-number generator.
Randomize
For i = 1 To 4
strResult = strResult & Mid(strChars, Int((Len(strChars) * Rnd) + 1), 1)
Next i
GenerateRandomString = strResult
End Function