+ Reply to Thread
Results 1 to 10 of 10

Calculating Average with variable range

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Calculating Average with variable range

    Hello,

    I am trying to come up with a way, without going into VBA or macros, to calculate averages with a variable #. Attached is a list of weeks(Col. A) with qty(Col. B). I would like to figure the average in Col. C of corresponding week, back X(D4) weeks. So for example, in week 10, if I entered "10" in D4, I would like to figure a 10 week average. If D4=5, then I would like to figure a 5 week avg, etc...
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculating Average with variable range

    Hi,

    Perhaps

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculating Average with variable range

    That would work based on the 10 weeks but if I try and change it, it figures the average from the top of the list, down. I need it to start in that week and work upwards. If it is a 5 week avg, in week 10, I would need the average of B6-B10

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculating Average with variable range

    Hi,

    What determines how many weeks you want to average? All D4 tells us, if I understand correctly, is the week which is the base week. i.e. how does the system know you want to average 5 weeks starting backwards at week 10?

  5. #5
    Registered User
    Join Date
    04-14-2014
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculating Average with variable range

    The user will determine how many weeks to average. I just picked 10 weeks to start... might have been a bad choice. D4 is the # of weeks that we need to have averaged. Each week would be the average of the last (D4) weeks.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Calculating Average with variable range

    Hi,

    Yes I understand that but how does the system know how many weeks to average? I was expecting to see another cell similar to D4 which would hold that value. i.e. the user would make an entry in D4 and this other cell and the system would count back and average the number of D4 weeks starting at the week defined by the other cell.

    Or by the 'last (D4) weeks' do you literally mean counting back from the highest (last) week, in your example data week 52?

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculating Average with variable range

    Maybe this...

    =AVERAGE(OFFSET(B2,COUNTA(B2:B53)-1,,-D4))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Calculating Average with variable range

    Pl see attached file.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-14-2014
    Location
    Indiana
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Calculating Average with variable range

    I figured it out. I manipulated kvsrinivasamurthy sheet by taking out the If argument and leaving it as an Average/Offset and setting the range indicator one cell below where i wanted the range to start. it seems to work..

    Thanks for everyone's help!!
    Attached Files Attached Files

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Calculating Average with variable range

    You're welcome. We appreciate the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help calculating an average using a named range
    By stacey69 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-19-2013, 09:48 AM
  2. Calculating average of a range
    By jazbath in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2013, 01:35 AM
  3. [SOLVED] Macro for calculating stats(ie, Average) over variable range
    By par315 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2012, 02:46 AM
  4. Replies: 3
    Last Post: 08-03-2012, 04:04 PM
  5. Div/0 Error when calculating average for a range
    By shilloh in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 05-19-2011, 08:23 AM

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