matevijay,
Just in case you'd like a macro solution, this one will produce 10000 unique alphanumeric entries very quickly and put them in column A of the active sheet starting in A1. I did use shg's method for getting a random alphanumeric character. I did my best to make it customizable. For a different number of results, change the (1 to 10000) in the Dim arrUnqAlphaNums line to be (1 to x) where x is the desired number of results. To change which characters can be used for your alphanumeric strings, change the strCharacters to only include the characters desired.
Sub tgr()
Const strCharacters As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim cllAlphaNums As Collection
Dim arrUnqAlphaNums(1 To 10000) As String
Dim varElement As Variant
Dim strAlphaNum As String
Dim AlphaNumIndex As Long
Dim lUbound As Long
Dim lNumChars As Long
Dim i As Long
Set cllAlphaNums = New Collection
lUbound = UBound(arrUnqAlphaNums)
lNumChars = Len(strCharacters)
On Error Resume Next
Do
strAlphaNum = vbNullString
For i = 1 To 16
strAlphaNum = strAlphaNum & Mid(strCharacters, Int(Rnd() * lNumChars) + 1, 1)
Next i
cllAlphaNums.Add strAlphaNum, strAlphaNum
Loop While cllAlphaNums.Count < lUbound
On Error GoTo 0
For Each varElement In cllAlphaNums
AlphaNumIndex = AlphaNumIndex + 1
arrUnqAlphaNums(AlphaNumIndex) = varElement
Next varElement
Range("A1").Resize(lUbound).Value = Application.Transpose(arrUnqAlphaNums)
Set cllAlphaNums = Nothing
Erase arrUnqAlphaNums
End Sub
And just in case...
How to use a macro:- Make a copy of the workbook the macro will be run on
- Always run new code on a workbook copy, just in case the code doesn't run smoothly
- This is especially true of any code that deletes anything
- In the copied workbook, press ALT+F11 to open the Visual Basic Editor
- Insert | Module
- Copy the provided code and paste into the module
- Close the Visual Basic Editor
- In Excel, press ALT+F8 to bring up the list of available macros to run
- Double-click the desired macro (I named this one tgr)
Bookmarks