skyline666
Programmer
hi,
Ive searched on this site and on internet with no luck
. The problem I have is that I need to be able to randomly select 3 even and 3 odd numbers from a range. Im using Excels VBA, so im sure this is right place to ask! What I would like is just to be able to use the function in the spreadsheet (e.g: =RandNum(1,45), 1 being lowest number and 45 highest) in 6 cells, to get 3 even numbers and 3 odd numbers, unless it would be easier to have 2 different functions, 1 for even numbers and 1 for odd. I have code to select a random number from the range, but not able to select an even or odd number. Here is the code I have so far:
Many thanks in advance,
Andrew
Ive searched on this site and on internet with no luck
Code:
Public Function RandNum(Lowest As Long, Highest As Long)
' Generates a random whole number within a given range
Randomize
RandNum = Int(Rnd * (Highest + 1 - Lowest)) + Lowest
End Function
Many thanks in advance,
Andrew