Probability Generator

wrx123

New Member
Joined
May 24, 2011
Messages
3
Hi,

Can anyone help? Basically, I have a list of projects and dates upon which these projects are likely to be undertaken. At the moment the model assumes 100% of these projects actually happen. What I want to do is insert a column that will use a different percantage that I can input mannually next to each date and generate a random selection of the dates from the date column which reflects the probability of the projects happening.

So it would look like this:

P1 01/02/11 10%
P2 01/09/12 100%
P3 01/06/13 50%

And what I need if for excel to calcualte a random selection of the projects actually happening based on the probabilities and creating an output for each of either say 1 or 0 as in yes it will happen or no it wont.

Any help would be amazing thank you
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
This formula can go in the cell next to the percentage you've supplied:
(Let's assume it is in D2):

=IF(RAND()<=C2,1,0)


Then fill down.
Results (1-->success, 0-->failure):

-----------------------------
| A  |         B | C    | D |
-----------------------------
| P1 |  1/2/2011 | 10%  | 0 |
| P2 |  1/9/2012 | 100% | 1 |
| P3 |  1/6/2013 | 50%  | 1 |
| P4 |  1/7/2013 | 40%  | 0 |
| P5 |  1/8/2013 | 12%  | 0 |
| P6 |  1/9/2013 | 45%  | 0 |
| P7 | 1/10/2013 | 89%  | 1 |
| P8 | 1/11/2013 | 9%   | 0 |
| P9 | 1/12/2013 | 60%  | 0 |
-----------------------------



The only drawback is it recalcs a lot since Rand() is volatile. If you want to hard code the results in I'd put a double click in the first cell (in D2). Then use a double click event to trigger a refresh when you want a new trial:

Code:
[COLOR="Navy"]Private[/COLOR] [COLOR="Navy"]Sub[/COLOR] Worksheet_BeforeDoubleClick(ByVal Target [COLOR="Navy"]As[/COLOR] Range, Cancel [COLOR="Navy"]As[/COLOR] Boolean)
    
    [COLOR="Navy"]If[/COLOR] Target.Address = "$D$2" [COLOR="Navy"]Then[/COLOR]
        Cancel = True
        Target.FormulaR1C1 = "=IF(RAND()<=RC[-1],1,0)"
        [COLOR="Navy"]If[/COLOR] Len(Target.Offset(1).Value) > 0 [COLOR="Navy"]Then[/COLOR]
            Range(Target, Target.End(xlDown)).FillDown
        [COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
    [COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]

[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]

<a href="http://northernocean.net/etc/mrexcel/20110525_sample.zip">SAMPLE WORKBOOK</a>
md5sum (zip file): c3b3fba4d5a51fc3f00801d8656751bd
sha256sum (zip file): 8a405d8e14859576902efec9b5d663053618f58649cfa8eff30916985d337e04

ξ
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

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