+ Reply to Thread
Results 1 to 8 of 8

Auto-incrementing dates

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,962

    Auto-incrementing dates

    Okay, here's a weird one:

    I have a series of macros that create a projection. During part of the process the user selects dates of history months to use in creating the projection from a userform. The history months available in the listbox need to be ONLY the month ending date for the 12 month period preceding the current month. So for today the range would be:

    12/31/2009
    1/31/2010
    2/28/2010
    3/31/2010
    4/30/2010
    5/31/2010
    6/30/2010
    7/31/2010
    8/31/2010
    9/30/2010
    10/31/2010
    11/30/2010

    I have these dates in a named range on my Sheet1, and each month I have to go update the range by adding the newest and deleting the oldest range.

    My question is: is there a date formula that I can put in the cells that will provide the dates, formatted as above, but for the current twelve month cycle? In other words, it would look at today's date and make a calculation as to which month it should be showing. I'm sure there's a formula that would do it, but date formulas aren't my strong suit.

    Thanks in advance for any help on this.
    Last edited by jomili; 12-30-2010 at 10:43 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Auto-incrementing dates

    You could use

    =EOMONTH(TODAY(),ROW(A1)-13)

    copied into the twelve cells in your range

    You will need to have the Analysis Toolpack installed to use the Eomonth function.
    Last edited by Huron; 12-29-2010 at 08:00 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,962

    Re: Auto-incrementing dates

    Huron,

    Your formula worked well for me, and I can make sure all of my customers have the Analysis Toolpack installed. But I wonder if you can help explain the formula to me? I tried to research, and here http://excel.tips.net/Pages/T002810_..._Function.html
    found this
    Please Login or Register  to view this content.
    So I can see in your formula "(TODAY()" takes the place of "NOW()" or "A1" from the examples above, and so "ROW(A1)-13" takes the place of the 0 or 6. But I don't understand what the "ROW(A1)-13" is doing. Should there be a value in A1? The formula seems to work without it, but I don't know why.

    BTW, thanks for providing it!

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

    Re: Auto-incrementing dates

    You can avoid the ATP requirement by simply using:

    Assume latest date is in last row:

    Please Login or Register  to view this content.
    then remaining dates:

    Please Login or Register  to view this content.
    above not ideal in so far as A1:A11 are looking down for their results but it's a nice short alternative... another approach:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Auto-incrementing dates

    Hi Jomili

    The "Row(A1)-13" is just a way of decreasing the argument of the EOMonth function automatically as the formula is copied down the column. Row(A1) is 1, Row(B1) is 2 etc so the formula becomes EOMonth(Today(),1-13) in the first row of your range and EOMonth (Today(),2-13) in the second row etc.

    DonkeyOte's suggestion's are probably better as they don't require the Analysis Toolpak.

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,962

    Re: Auto-incrementing dates

    DonkeyOte,
    I like your second solution, as it's only one formula, so based on Huron's recommendation I'll go with that one.

    Huron,

    Thanks for the great explantion of the ROW argument. It helps me to understand not only your formula but DonkeyOte's as well.

    Thanks for all the help!

    Happy New Year!

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

    Re: Auto-incrementing dates

    Quote Originally Posted by jomili View Post
    Thanks for the great explantion of the ROW argument. It helps me to understand not only your formula but DonkeyOte's as well
    FWIW, I prefer ROWS to ROW as the latter is susceptible to error should the source sheet be physically modified in a particular way.

    ROW is preferable/necessary where you want to return an Array of values else I always opt for ROWS - same holds true for COLUMN & COLUMNS obviously.

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,962

    Re: Auto-incrementing dates

    Thanks for the great lessons on ROW vs ROWS. Food for thought for me.

+ 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