+ Reply to Thread
Results 1 to 10 of 10

Average last n numbers ignoring blanks

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Average last n numbers ignoring blanks

    Hello,

    Martindwilson provided this formula on a different thread:

    =AVERAGE(OFFSET(P3,,MATCH(1E+100,P3:AAD3)-A1,1,A1))

    It almost works for me but I need it to ignore cells that are empty.

    Can some one help me out please?

    Many Thanks

    C.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Average last n numbers ignoring blanks

    Hi Cryptic,

    welcome to the forum.

    And those n number range is including blanks for example - last 20 numbers to be averaged in a range of A1:A100 so will your consider A80:A100 or A75:A100 if 5 are blank cells in both the cases ?



    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    05-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Average last n numbers ignoring blanks

    Thanks DILIPandy

    In a range of A1 to A100 where there are 5 blank cells I need the average of the last 20 numbers.
    So, if A81 and A82 are blank the range to be averaged would be A78 to A100 with the total still being divided by 20 and not 22.

    Regards

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Average last n numbers ignoring blanks

    H Cryptic

    See the attached file where I have used a defined name "data" having logic as:-
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    It will always count last 20 values - ignoring blanks. You can change 20 to your choice OR reference that from a cell.

    average of last n ignoring blanks.xlsx

    Regards,
    DILIPandey
    <click on below * if this helps>

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Average last n numbers ignoring blanks

    You could try this CSE array Confirm with Ctrl+Shift+Enter not just Enter
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    To avoid the CSE entry you can use a defined name
    Name:= "DataRows"
    Refers to:=
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    Change 10 to suit
    Attached Files Attached Files
    Last edited by Marcol; 06-02-2013 at 04:49 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Registered User
    Join Date
    05-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Average last n numbers ignoring blanks

    Thanks Marcol
    Run out of time to look at this properly tonight and the server is really slow.
    I will try again tomorrow.
    Thanks again

  7. #7
    Registered User
    Join Date
    05-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Average last n numbers ignoring blanks

    Hello again,
    I have tried unsuccessfully to modify some of your suggestions to work on my spread sheet.
    I have attached a sample (which is, of course, what I should have done in the first place).
    I need to find the average of the last n numbers(A1)in each row while ignoring the blank cells.
    Thanks for helping again.
    Attached Files Attached Files

  8. #8
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Average last n numbers ignoring blanks

    I'm getting really peed off with this site crashing.

    See if this workbook does as you need.

    Column AI averages the last n elements if there are at least n elements in the row, if not "" is returned.

    Column AK averages the last n elements if there are less than n elements the whole row is averaged.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Average last n numbers ignoring blanks

    Thanks very much Marcol,
    This is exactly what I needed. I don't fully understand how it works but you have made me look a like genius!
    Thanks again
    C

  10. #10
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Average last n numbers ignoring blanks

    Happy to have helped.

    Be careful, they will just load more work on you ...

+ 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