+ Reply to Thread
Results 1 to 3 of 3

Macro to run scenarios and save cash flows to corresponding scenario sheets

Hybrid View

dariushou Macro to run scenarios and... 06-14-2008, 05:45 PM
Paul Dariushou, Please read the... 06-14-2008, 09:29 PM
VBA Noob pjoaquin, I did ask... 06-15-2008, 02:57 AM
  1. #1
    Registered User
    Join Date
    06-13-2008
    Posts
    3

    Macro to run scenarios and save cash flows to corresponding scenario sheets

    I'm new to macros so forgive me ahead of time. Here's my issue. I've created a macro that amoritzes and aggregates the cash flows from rows of assumptions for each loan. That's great for one scenario, but i would also like to add 8 more scenarios for a total of 9. I have my assumptions next the loan name across many columns. My list of loans are currently in order like this:

    Loan 1
    Loan 2


    I would like to order them like this with mulitple scenarios:

    Loan 1 Scenario 1
    Loan 1 Scenario 2
    Loan 2 Scenario 1
    Loan 2 Scenario 2
    and so on

    Each scenarios cash flows need to be aggregated in its own worksheet (ex. scen1 and scen2 and so on). There will end up being 28 different loans and 9 scenarios (total of 252 rows of assumptions). I'm not sure how to get the cash flows from each scenario into its correct sheet. Because i have it grouped by loan instead of scenario, it will have to move down each loans respective 9 scenarios before moving to the next loan. As it is moving down scenarios it will need to write the related scenario sheet (scen1, scen2...). Each loan will always be run the same number of scenarios as the other bonds.

    It would be neat if i could simply turn the scenarios on and off with a check box or even entering in the number of scenarios i want to run out of the 9 for each loan as well as turning on and off the loans i want to run. Way beyound my skills though.

    Here is what i have that does one scenario correctly.

    Thanks ahead of time,

    Darius


    Sub Aggregate_My_Principal_Balances()
    numLoans = 28
    
    Worksheets("Scen1").Range("C12:aq393").ClearContents
    
    For currLoan = 1 To numLoans
    
    Worksheets("Assum2").Range("Q38") = currLoan
    Worksheets("Mod").Range("gi12:hw393").Copy
    Worksheets("Scen1").Range("C12:aq393").PasteSpecial Paste:=xlPasteValues
    Application.CutCopyMode = False
    
    Next currLoan
    
    End Sub
    Items from the Macro:

    Scen1 = The sheet that will total the cash flows for scenario 1. The data that i'm aggregating is aggranged over several columns.

    Assum2 --cell Q38 = A box where you enter the corresponding row of assumptions to run through the model--with each row indicating one of the 9 rows of assumptions for each loan.

    Mod--This is the amortizer. The cells that are in the macro from this sheet are summing the current loans cash flows that is indicated on the Assum2 sheet together to the previously run loans cash flows. The previous months cash flows is in the related scenario sheet.

    thanks Again.
    Last edited by Paul; 06-14-2008 at 09:27 PM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,887
    Dariushou,

    Please read the forum rules (link in my signature, or post at the top of each forum), paying close attention to the rules regarding wrapping any code text with proper code tags [ code ] and [ /code ] (without the spaces), as well as posting to the correct forum. I've added the code tags this time, and moved the post to the correct forum.

    In the future, posts that do not adhere to the forum rules may be locked or deleted.

    Thank you,
    Paul

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    pjoaquin,

    I did ask dariushou earlier to read the forum rules as he had poor title. Now he not wrapping his code and also cross posting

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1