I need help for a Random Number Generator

xr600rr

New Member
Joined
May 20, 2003
Messages
8
Hello, I need some help. What I need is a random number generator for numbers 1-9. It needs: 1 number per cell in a column and the numbers can not be the same. i.e.:
4
1
2
6
8
5
3
7
9

I have a VB mod that will produce the numbers but all the numbers appear in the same cell:

Function RandLotto(Bottom As Integer, Top As Integer, _
Amount As Integer) As String
Dim iArr As Variant
Dim i As Integer
Dim r As Integer
Dim temp As Integer

Application.Volatile

ReDim iArr(Bottom To Top)
For i = Bottom To Top
iArr(i) = i
Next i
For i = Top To Bottom + 1 Step -1
r = Int(Rnd() * (i - Bottom + 1)) + Bottom
temp = iArr(r)
iArr(r) = iArr(i)
iArr(i) = temp
Next i
For i = Bottom To Bottom + Amount - 1
RandLotto = RandLotto & " " & iArr(i)
Next i
RandLotto = Trim(RandLotto)
End Function

With =randlotto(1,9,1) as the formula for the cell.

Any Ideas?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Mark W. said:
Mark, TRUE is the range_lookup value that requires the table_array to be sorted on its leftmost column -- not FALSE.

Mark,

Thanks,

Mark

Sorry, couldn't resist. That's the sort of email that my boss, Mark, sends to me it bugs the hell out of me. Seriously thanks for correcting me.
 
Upvote 0
Based on Mark W.'s correction, I recreated your worksheet and:

=VLOOKUP(1,$B$13:$D$21,3,FALSE)

works fine for me. It does not return #N/A
 
Upvote 0
OK, Dont know what I did but I re entered everything and it works! Thanks all for your help. :D :D :D
 
Upvote 0

Forum statistics

Threads
1,221,701
Messages
6,161,381
Members
451,700
Latest member
Eccymarge

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