+ Reply to Thread
Results 1 to 10 of 10

Averaging a range of cells if before a certain date

  1. #1
    Registered User
    Join Date
    07-19-2011
    Location
    st. louis
    MS-Off Ver
    Excel 2007
    Posts
    19

    Averaging a range of cells if before a certain date

    I am trying to average the range s4:s219 (omitting #DIV/0!) with a couple of criteria:
    average s4:s219 if
    c4:c219 <8/1/2009 and
    d4:d219 =Y

    Here is the current formula I've been trying to work with, with no success so far.

    =IFERROR(AVERAGEIFS($S$4:$S$219,$D$4:$D$219,"=Y",$C$4:$C$219,"<8/1/2009"),0)
    Last edited by markl41; 07-19-2011 at 11:41 AM.

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

    Re: Averaging a range of cells if before a certain date

    It works for me.

    Are you sure the format of the dates in column C is the same as in the formula: 8/1/2009

    ie. is that August 1, 2009 or Jan 8, 2009?

    You can replace that part with the DATE(year,month,day) function to make it easier possibly.

    =IFERROR(AVERAGEIFS($S$4:$S$219,$D$4:$D$219,"=Y",$C$4:$C$219,"<"&DATE(2009,8,1)),0)

    change the 8 and 1 around if you mean Jan 8, 2009
    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
    07-19-2011
    Location
    st. louis
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Averaging a range of cells if before a certain date

    I mean Aug 1, 2009 and yes the date format is the same.

    The formula you've provided returns the same result I've been getting. The formula will return the zero, or whatever number is entered in the last slot after the comma for the =iferror function.

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

    Re: Averaging a range of cells if before a certain date

    Are you sure there is a Y in column D at corresponding rows... and also that those Y's don't have an additional space or two before or after the letter....?

    If you take out the IFERROR part do you get an error or 0?

  5. #5
    Registered User
    Join Date
    07-19-2011
    Location
    st. louis
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Averaging a range of cells if before a certain date

    Every cell in column C has a value (a date), not every cell in column D has a Y. There are no spaces before or after the Y.

    I want the cells to average in column S if column D has a Y and column C is <8/1/2009

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Averaging a range of cells if before a certain date

    Compare the attached file to yours...Do you see any important differences?
    Attached Files Attached Files
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

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

    Re: Averaging a range of cells if before a certain date

    Can you post the workbook or sample?

    Like I said the formula should work if the conditions you set are true....

  8. #8
    Registered User
    Join Date
    07-19-2011
    Location
    st. louis
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Averaging a range of cells if before a certain date

    Here is a sample.

    Ron,

    Designating the date as its own cell and referencing the cell location rather than typing in the date didn't work either. I understand why it works on yours and I figure it'd work for me, but unfortunately it doesn't.
    Attached Files Attached Files

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

    Re: Averaging a range of cells if before a certain date

    It is because you have cells in column S with text (i.e. #DIV/0!)

    You need to exclude those:

    Try:

    =IFERROR(AVERAGEIFS($S$4:$S$219,$S$4:$S$219,"<>#DIV/0!",$D$4:$D$219,"=Y",$C$4:$C$219,"<"&DATE(2009,8,1)),0)

  10. #10
    Registered User
    Join Date
    07-19-2011
    Location
    st. louis
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Averaging a range of cells if before a certain date

    That works!

    Thank you very much NBVC and Ron.

+ 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