Not sure if this improves the speed of MarkT's code, but it does seem to knock out 4 looping iterations:
Code:Option Explicit Private Sub Command1_Click() MsgBox GenerateSerialNumber End Sub Private Function GenerateSerialNumber() As String Dim strChar(3) As String, i As Integer Randomize For i = 0 To 3 If i < 3 Then strChar(i) = Chr(Int(Rnd() * 26) + 65) Else strChar(i) = Format$(Int(Rnd() * 100000), "00000") End If Next i GenerateSerialNumber = Join(strChar, "") End Function




Reply With Quote