VBA Sensitivities Analysis

smurr13

New Member
Joined
Apr 9, 2019
Messages
6
Office Version
  1. 365
Hello All -- I've been slowly trying to build some VBA into my cash flow model in order to more efficiently run sensitivity analysis. To add some color, I run 24 sensitivity tables flexing a number of variables (see below); some are 1-way tables and some are 2-way.

What I am trying to accomplish now is incorporating a 3rd or 4th variable. For a majority of the sensitivity tables I am running them assuming the use of Price Deck '1'. However for a few of the tables I'd like it to flip to Price Deck '2', '3', etc. before running. My code below is as far as I've gotten. My ultimate goal is to be able to run the 'batch' code to run all tables, adjusting the variables as it goes. Currently I am having to run macro, change variable, repeat.

Any help/references would be greatly appreciated!

VBA Code:
Sub table()
    
initial_row = Range(Range("row_variable"))
initial_col = Range(Range("col_variable"))

For Row = Range("row_start") To Range("row_end")
    Range(Range("col_variable")) = Cells(Row, Range("col_start") - 1)
    
    For col = Range("col_start") To Range("col_end")
        On Error Resume Next
        Range(Range("row_variable")) = Cells(Range("row_start") - 1, col)
        
        Cells(Row, col) = Range(Range("output"))
    Next col
Next Row

Range(Range("row_variable")) = initial_row
Range(Range("col_variable")) = initial_col
    
    
   
End Sub


Sub batch()

For code = Range("Beg_Code") To Range("End_Code")
    Range("code") = code
    table
Next code

End Sub

1649877598505.png
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Was there ever an answer for this? Trying to create two, two variable sensitivities through VBA, and have it return project level levered IRR and MOIC as outputs
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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