+ Reply to Thread
Results 1 to 6 of 6

Need Help with Array Formula

  1. #1
    Registered User
    Join Date
    12-06-2010
    Location
    florida usa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Need Help with Array Formula

    I am looking for an formula that will give me the average of the last 10 entries in a column.
    I have tried the following formulas, but they are not giving me the correct average:
    =AVERAGE(OFFSET(N$1,MAX(COUNT(N:N)-10,0),,10))
    =INDEX(Sheet2!$A$1:$E$5,MATCH($A1,Sheet2!$A$1:$A$5,0),COLUMN())

    Any help would be appreciated.
    Last edited by sjd319; 03-21-2012 at 12:37 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Need Help with Array Formula

    How is this one not working?

    =AVERAGE(OFFSET(N$1,MAX(COUNT(N:N)-10,0),,10))

    If you have numbers in consecutive cells from N1 down, then it works.

    if there are blanks at the top of the list, this is an alternative:

    =AVERAGE(OFFSET(N$1,MATCH(9.9999E+307,N:N)-10,,10))
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    12-06-2010
    Location
    florida usa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Need Help with Array Formula

    You are getting close i think. there are empty cells between entries. is there a formula that will only average those cells, the last 10 entries, that have values in the cells?

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Need Help with Array Formula

    Perhaps then an array formula:

    =AVERAGE(IF(N1:N100<>0,IF(ROW(N1:N100)>=LARGE(IF(N1:N100,ROW(N1:N100)),10),N1:N100)))

    confirmed with CTRL+SHIFT+ENTER not just ENTER.

    Note: It is not recommended to use whole columns with array formulas due to inefficiency... but you can use a dynamic named range...

    Define a new Named range (through formula tab) as "List" with formula: =Sheet2!$N$1:INDEX(Sheet2!$N:$N,MATCH(9.99E+307,Sheet2!$N:$N))

    then change average formula to:

    =AVERAGE(IF(List<>0,IF(ROW(List)>=LARGE(IF(List,ROW(List)),10),List)))


    confirmed with CTRL+SHIFT+ENTER not just ENTER.

  5. #5
    Registered User
    Join Date
    12-06-2010
    Location
    florida usa
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Need Help with Array Formula

    you got it NBVC. so many thanks. i have been screwing around with this formula for years. made my day. thanks again.

  6. #6
    Forum Contributor darknation144's Avatar
    Join Date
    01-24-2012
    Location
    London
    MS-Off Ver
    Microsoft Excel 365 MSO
    Posts
    555

    Re: Need Help with Array Formula

    Please mark the thread as solved. Check the FAQ's to see how.

+ 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