+ Reply to Thread
Results 1 to 9 of 9

Changing an Average formula

  1. #1
    Registered User
    Join Date
    12-24-2008
    Location
    Boerne, Texas
    Posts
    10

    Changing an Average formula

    I am trying to optimize on an average in a spreadsheet. My result depends on the length of the average. I would like to be able to enter a value in a cell and change the length of an average.
    For instance, if the value in the cell is 10, the formula would be =Average(A2:A11), but if the value in the cell is 20, the formula would change to =Average(A2:A21).
    The goal is to have one cell that changes the length of all of the average formulas that "call" that cell. Is this possible?

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Changing an Average formula

    Hi.

    Assuming the cell which holds your choice is B1:

    =AVERAGE(A2:INDEX(A:A,B1+1))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Valued Forum Contributor mahju's Avatar
    Join Date
    11-27-2010
    Location
    Pakistan, Faisalabad
    MS-Off Ver
    Excel 2010 plus
    Posts
    730

    Re: Changing an Average formula

    Another approach

    B1 is choice cell.

    Please Login or Register  to view this content.
    Thanks
    Mark the thread as solved if you are satisfied with the answer.


    In your first post under the thread tools.

    Mahju

  4. #4
    Registered User
    Join Date
    12-24-2008
    Location
    Boerne, Texas
    Posts
    10

    Re: Changing an Average formula

    After working with this I realized that I mis-stated the question. It is a moving average that I am trying to use, so the range of cells move with each row. When I use the concepts above it calls a single stationary cell. What I need to call is a moving cell that gives me a 20 row moving average, or a 25 row moving average, or a 60 row moving average. Is that possible?

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Changing an Average formula

    So how would you know where the average starts and ends?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    12-24-2008
    Location
    Boerne, Texas
    Posts
    10

    Re: Changing an Average formula

    I seem to be unable to upload an image. Column A has a list of daily prices. Column B is the 20 period moving average of those prices. So B1 shows the average of A1 through A21. B2 shows the average of A2 through A22... and so on. Column A has thousands of rows. I would like to be able to vary the length of the moving average with a number placed in say cell D1. If D1 is 20, it calculates a 20 period moving average. Does this answer the question? (I apologize for not wording my questions clearer. I am realizing how difficult it is to frame the question correctly.) I appreciate the help.

  7. #7
    Valued Forum Contributor
    Join Date
    04-22-2014
    Location
    Auckland, New Zealand
    MS-Off Ver
    Office 365 (work) and Excel 2013 (home)
    Posts
    1,167

    Re: Changing an Average formula

    In B2 and copied/dragged down:
    =AVERAGE(OFFSET(A2,0,0,$D$1,1))
    Please add reputation by clicking on the * if I have helped.
    Please mark the thread SOLVED if your issue has been resolved.
    Thanks, Glenn.

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,939

    Re: Changing an Average formula

    we cant use images anyway, you would need to upload a sample workbook.

    Anyway, try this...
    A
    B
    C
    1
    1
    5
    10
    2
    2
    10
    3
    3
    4
    4
    5
    5
    6
    6
    7
    7
    8
    8
    9
    9
    10
    10
    11
    11
    12
    12
    13
    13
    14
    14
    15
    15
    16
    16
    17
    17
    18
    18
    19
    19
    20
    20

    B1=start position
    B2=number of "rows"
    C1=AVERAGE(INDEX(A:A,B1):INDEX(A:A,B1+B2))

  9. #9
    Registered User
    Join Date
    12-24-2008
    Location
    Boerne, Texas
    Posts
    10

    Re: Changing an Average formula

    =AVERAGE(OFFSET(A2,0,0,$D$1,1))
    Works! Thank you all very much.

+ 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. average with changing start and end points
    By puzzlelover22 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-02-2014, 12:28 PM
  2. [SOLVED] Formula to work out the average of an array from a changing cell
    By francesc in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-06-2014, 10:00 PM
  3. Changing average
    By initias in forum Excel General
    Replies: 5
    Last Post: 11-12-2010, 04:47 AM
  4. Formula for weekly average & changing daily formula
    By sandbach in forum Excel General
    Replies: 2
    Last Post: 11-01-2010, 08:15 PM
  5. Changing conditional average formula to conditional sumproduct
    By chlor in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2007, 11:39 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