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!
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