Static Randomisation Probability

Steven101

Board Regular
Joined
Oct 27, 2014
Messages
62
Hi, I have the following formula working out a random Yes / No based on some probability.

In B23 I have the following code (it sits in a table)

Code:
=IF(A23="","",INDEX($A$2:$A$3,COUNTIF($C$2:$C$3,"<="&RAND())+1))

However as more data gets added below A23, it recalculates.

What I'm looking for is a static calculation, so that when A23 is populated B23 calcs once. Then when A24 is populated B24 calculates, but B23 remains static and does not change.

I've got the following vba code in a module and B23 has =StaticRand5. It works for this but how do I get it to do the
Code:
=IF(A23="","",INDEX($A$2:$A$3,COUNTIF($C$2:$C$3,"<="&RAND())+1))


Code:
Function StaticRand5() As Double
StaticRand5 = Int((20 - 1 + 1) * Rnd() + 1)
End Function

any help would be appreciated. Thanks S
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Ok, so I know I need to create a Function to run my calculation, however I'm trying the following code and get "0" value?

Code:
Function StaticRand() As Double
StaticRand = Evaluate("INDEX(A2:A3,COUNTIF(C2:C3," <= "&RAND())+1)")
End Function

Any help would be appreciated.

Thanks S
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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