Fast way to generate unique strings
Don't know about the fastest, but this returns 100 strings of 100
characters in the blink of an eye...
Public Function GetUniqueStrings( _
ByRef Strings() As String, Length As Long)
Dim i As Long
Dim j As Long
For i = LBound(Strings) To UBound(Strings)
Strings(i) = Space(Length)
For j = 1 To Length
Mid(Strings(i), j, 1) = Chr(Int(97 + Rnd() * 26))
Next j
Next i
End Function
Called as:
Public Sub try()
Dim s(1 To 100) As String
GetUniqueStrings s, 100
Range("A1").Resize(UBound(s)).Value = Application.Transpose(s)
End Sub
In article ,
R Avery wrote:
what is the fastest VBA code to generate a list of random strings of a
specified length.
the function prototype i want is
sub GetUniqueStrings(Strings() as string, Length as long)
|