Friday, May 18, 2018

how to generate a random number in excel vba - open code - vbatip#50





Dim strtnumber As Long
Dim endnumber As Long
Dim rslt As Long
Dim rsltString As String

strtnumber = Sheet1.Range("A1")
endnumber = Sheet1.Range("A2")

rslt = (endnumber - strtnumber) * VBA.Rnd + strtnumber

If VBA.InStr(rsltString, rslt) = 0 Then
MsgBox rslt
rsltString = rsltString + ", " + CStr(rslt)
End If

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.