RANDBETWEEN (Excel 2007)

steveh
SilverLounger
Posts: 1952
Joined: 26 Jan 2010, 12:46
Location: Nr. Heathrow Airport

RANDBETWEEN (Excel 2007)

Post by steveh »

Good morning

I am trying to get into using 2007 and I am experimenting with the RANDBETWEEN function and to do that I have made a worksheet to select Euro Lottery numbers. The basic layout is therefore 5 rows numbered ball 1, ball 2 etc. each with the formula =RANDBETWEEN(1,50) and 2 for the bonus balls that have the formula RANDBETWEEN(1,9).

What I had not allowed for was duplicates, is there something I can add to the formula to stop duplicates without using VBA. I have tried the RAND feature but that does not seem to allow me to put anything in between the brackets. Tushar Metha's site gives some code examples and some other examples using RAND and RANK but it was the RANDBETWEEN that I was particularly interested in
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin

User avatar
HansV
Administrator
Posts: 78642
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: RANDBETWEEN (Excel 2007)

Post by HansV »

Neither RAND nor RANDBETWEEN have built-in support for generating unique random numbers; you need either VBA code or elaborate formulas involving other functions such as SMALL or RANK in combination with RAND.
RANDBETWEEN does not offer any specific advantage in this respect, so you might as well use one of the many existing solutions.
Best wishes,
Hans

steveh
SilverLounger
Posts: 1952
Joined: 26 Jan 2010, 12:46
Location: Nr. Heathrow Airport

Re: RANDBETWEEN (Excel 2007)

Post by steveh »

HansV wrote:Neither RAND nor RANDBETWEEN have built-in support for generating unique random numbers; you need either VBA code or elaborate formulas involving other functions such as SMALL or RANK in combination with RAND.
RANDBETWEEN does not offer any specific advantage in this respect, so you might as well use one of the many existing solutions.
Hi Hans

Thanks for that advice. Not having seen this function in previous versions I thought it might offer more in flexibility so I was just experimenting and wondered if it could be more useful than just picking one number
Steve
http://www.freightpro-uk.com" onclick="window.open(this.href);return false;
“Tell me and I forget, teach me and I may remember, involve me and I learn.”
― Benjamin Franklin