+ Reply to Thread
Results 1 to 5 of 5

Dynamic Formulas and Sheet Insertion

  1. #1
    Registered User
    Join Date
    04-15-2009
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    8

    Dynamic Formulas and Sheet Insertion

    I have a spreadsheet containing Sheets for each month of the year, Jan-09 through Apr-09 (this month). Each sheet contains large amounts of data - some of which is based off of a formula ( =H11-Mar-09!H11 ) for example.

    It is very awkward to create entirely new formulas each month - is there a way to automatically update the formula upon insertion of a new sheet? We make sure that the sheet containing the most recent month's data is listed first, followed by previous months in order.

    A non-VBA solution is preferred, but VBA may be used as a last resort.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Dynamic Formulas and Sheet Insertion

    When you copy Apr-09 sheet to become May-09 you could run an Edit -> Replace on your cells ... Replacing: What: 'Mar-09'! With: 'Apr-09'!

    Other than that you're looking at using INDIRECT based off a date value, however, INDIRECT is a Volatile function and in big models Volatiles should be avoided else performance will be affected.

    For more info. on Volatiles see Charles Williams' site: http://www.decisionmodels.com/calcsecretsi.htm

  3. #3
    Registered User
    Join Date
    04-15-2009
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Dynamic Formulas and Sheet Insertion

    I finally found a non-VBA solution! Just in case anyone was wondering:

    First, define the following names:

    AllSheets
    =GET.WORKBOOK(1+0*now())

    ThisSheet
    =GET.CELL(32+0*now(),indirect("rc",False))

    PrevSheet
    =INDEX(AllSheets,MATCH(ThisSheet,AllSheets,0)-1+0*now())

    NextSheet
    =INDEX(AllSheets,MATCH(ThisSheet,AllSheets,0)+1+0*now())

    The formula (for my example above) ends up being:

    =F11-INDIRECT("'"&NextSheet&"'!"&CELL("address"),F11))

    Now, every time I insert a new sheet, the formulas automatically update!

  4. #4
    Registered User
    Join Date
    04-15-2009
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Dynamic Formulas and Sheet Insertion

    Uh oh - it's not working anymore. I closed the spreadsheet and re-opened it, and now I am getting #name! errors. I am not 100% sure, but my guess is that the GET.WORKBOOK and GET.CELL functions are causing it. Why did these formulas work earlier, but not now?

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Dynamic Formulas and Sheet Insertion

    GET.WORKBOOK and GET.CELL are old Excel4 Macros, you will need to save the file as a macro enabled type - ie .xlsm or for legacy purposes .xls (.xlsm offers greater compression)

+ 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