I think this worksI tried on 3000 cells and got![]()
=IF(RAND()>0.5,"Dog",IF(AND(RAND()>0.2,RAND()<=0.5),"Cat","Rabbit"))
Does this work for you?![]()
Cat 20 Dog 51 Rabbit 29
I think this worksI tried on 3000 cells and got![]()
=IF(RAND()>0.5,"Dog",IF(AND(RAND()>0.2,RAND()<=0.5),"Cat","Rabbit"))
Does this work for you?![]()
Cat 20 Dog 51 Rabbit 29
ChemistB
My 2?
substitute commas with semi-colons if your region settings requires
Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)
Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble
Hi, thanks for the formula.
The logic of the formula looks 100% correct but the cat & rabbit results come out the wrong way round. Its something to do with the random function which appears 3 times in the formula, perhaps Excel recalculates as it steps through the formula.
To test this I took the rand() function out of the calculation and put it into cell D1 so there could only be one random number in each row.
Changing the formula to
=IF(D1>0.5,"Dog",IF(AND(D1>0.2,D1<=0.5),"Cat","Rabbit"))
This does return 500 dog, 300 cat and 200 rabbit
Strange.Oh well, your method will work just fine.
![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks