Hi
I am fairly new to function/vba and I have tried to create a pin gernerator using the following function
Public Function RandomizeF(Num1 As Integer)
Dim Rand As String
Application.Volatile
getLen = Num1
Do
j = j + 1
Randomize
Rand = Rand & Chr(Int((85) * Rnd + 38))
Loop Until j = getLen
RandomizeF = Rand
End Function
and then calling it through
Private Sub CommandButton1_Click()
Dim myvalue As Integer, myvalue2 As Integer, i As Integer
myvalue = InputBox("enter number between 5 and 10")
myvalue2 = InputBox("enter number of pins required")
For i = 1 To myvalue2
Cells(i, 1).Value = RandomizeF(myvalue)
Next i
End Sub
When asking for large numbers of pins (i have been testing with 100 but will require more) it sometimes works but other times throws the error shown it the title. When opening the debug the line Cells(i, 1).Value = RandomizeF(myvalue) is shown as the error
Any ideas as what is causing this and how to correct it.
Many thanks
Dave
Bookmarks