Monte Carlo VBA Probability Macro

dmac2781

New Member
Joined
Apr 4, 2015
Messages
1
I am trying to create a Macro/formula that calculates the probability that the value of a property is greater than a "Goal" value (which is an input). I want the value to be calculated a certain number of times, hence the Do While Loop, just like a Monte Carlo Simulation. I am very new to working in VBA so please excuse any basic errors. Here is the code I tried to write:

Function Probability_Profit(NOI, CapRate_Avg, CapRate_STDV, PurchasePrice, Goal, Trials)
n = 0
g = 0
CapRate = Application.NormInv(Rnd(), CapRate_Avg, CapRate_STDV)


Do While n < Trials


Value = NOI / CapRate - PurchasePrice
If Value > Goal Then
g = g + 1
Else
g = g
End If

n = n + 1

Loop
Probability_Profit = (g / Trials) * 100


End Function
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,215,129
Messages
6,123,210
Members
449,090
Latest member
bes000

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