Pick a random number between 1 and 3 that isn't in B2 or F2

geewhysee

New Member
Joined
Jan 7, 2016
Messages
32
I'm trying to do a quick excel sim of the monty hall problem. I've used RANDBETWEEN(1,3) in columns B and and F for the initial guess and the actual winning door however I need to determine which door is opened. Basically my question is how do I make excel do my title, pick a random number between 1 and 3 but if the value picked matches the value in B2 or F2 then pick again.

I tried just writing out all the possibilities but got stuck here

=if(and(B2=1,F2=1),RANDBETWEEN(2,3),if(and(b2=1,f2=2),3,if(and(b2=1,f2=3),2,if(and(b2=2,f2=1),3,if(and(b2=2,f2=2),RANDBETWEEN(...

because I want to pick randomly either the number 1 or the number 3 and I don't know of a way to make excel do that.

Any ideas?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Wow actually never mind I just figured it out. Add another if with randbetween(1,2)

=IF(AND(B2=1,F2=1),RANDBETWEEN(2,3),IF(AND(B2=1,F2=2),3,IF(AND(B2=1,F2=3),2,IF(AND(B2=2,F2=1),3,IF(AND(B2=2,F2=2),IF(RANDBETWEEN(1,2)=1,1,3),IF(AND(B2=2,F2=3),1,IF(AND(B2=3,F2=1),2,IF(AND(B2=3,F2=2),1,IF(AND(B2=3,F2=3),IF(RANDBETWEEN(1,2)=1,1,2),"whoops")))))))))
 
Upvote 0
See formula in J2:


Book1
BCDEFGHIJ
2113
3123
4132
5213
6223
7231
8312
9321
10331
Sheet1
Cell Formulas
RangeFormula
J2=IF(B2=F2,RANDBETWEEN(1,2)*(2-MOD(B2,2))-(B2=2)+(B2=1),VLOOKUP(B2*10+F2,{12,3;13,2;21,3;23,1;31,2;32,1},2,FALSE))


WBD
 
Upvote 0
If B2 and F2 have different random numbers between 1 and 3, and you want to get the other number, you can do it much simpler like this:

=6-B2-F2
 
Last edited:
Upvote 0
Doh! Of course!! Change my formula to:

Code:
=IF(B2=F2,RANDBETWEEN(1,2)*(2-MOD(B2,2))-(B2=2)+(B2=1),6-B2-F2)

WBD
 
Upvote 0
The numbers can be the same. They're both just random numbers between 1 & 3 imclusive
 
Last edited:
Upvote 0
Here is another formula that will work...

=MID(SUBSTITUTE(SUBSTITUTE("123",B2,""),F2,""),RAND()*(2-(B2<>F2))+1,1)
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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