+ Reply to Thread
Results 1 to 4 of 4

Averaging values that move within a range

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    9

    Averaging values that move within a range

    Hello,

    I have a model that populates monthly price data based on a user input of start date and contract length. For example: If the user selects to run the model for 24 months starting July-2013, the price data for 24 months starting in July-2013 will show up in a range of cells corresponding to those months.

    I want to set up a formula that calculates the average price for the first half of the input period. So if the user specifies the start date and contract length as above, the formula will average the first 12 months of price data starting in July 2013. Since both the start date and number of months changes based on user input, coming up with a formula is proving to be a bit difficult. I think the offset function would come into play here somehow but not exactly sure.

    Thanks for your assistance.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Averaging values that move within a range

    Maybe the AVERAGEIFS() can be used to set the date range.

    Assuming:

    Dates in column A
    Values in column B
    Start date in D1
    Number of months in E1


    First half
    =AVERAGEIFS(B:B, A:A, ">="&D1, A:A, "<"&Date(Year(D1), Month(D1)+(E1/2), Day(D1)))

    Second half
    =AVERAGEIFS(B:B,A:A, ">="&DATE(YEAR(D1), MONTH(D1)+(E1/2), DAY(D1)),A:A, "<"&DATE(YEAR(D1), MONTH(D1)+E1, DAY(D1)))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    04-09-2013
    Location
    Calgary, Alberta
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Averaging values that move within a range

    Perfect..works exactlty as needed. Thanks for the help friend.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Averaging values that move within a range

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Thanks.

+ 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