VBA Program for Random Generator

Switm

New Member
Joined
Mar 20, 2011
Messages
2
I have this program written in VBA:

Function GetFive()
Dim iNum As String
Dim iNum2 As String
Dim strNum As String
Dim i As Integer
Dim j As Integer
Dim Counterko As Integer
Dim checker(1 To 5) As String
Counterko = Int((22 * Rnd) + 1)
iNum = "A" & Counterko
strNum = Worksheets("Sheet1").Range(iNum).Value
iNum2 = iNum
For i = 1 To 5
strNum = Trim(strNum & " " & strNum2)
'MsgBox (strNum)
checker(i) = iNum2
' MsgBox ("i=" & i & "iNum2=" & iNum2)
Counterko = Int((22 * Rnd) + 1)
iNum2 = "A" & Counterko
For j = 1 To i
If iNum2 = checker(j) Then
i = i - 1
strNum2 = ""
Exit For
Else
iNum = iNum2
strNum2 = Worksheets("Sheet1").Range(iNum2).Value
End If
Next j
Next i

Now I need to add that will choose a number between for the first number 1-17, second number 4-30, third number 12-42, fourth number 28-52 and fifth number 38-56 and it would give me a 15 group of numbers. I am also would like to add the "click" button. I not realy good in doing this kindna I just combined what i found in the internet but I can't seem to find this one. Thanks in advance.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top