+ Reply to Thread
Results 1 to 8 of 8

Average Formula that excludes specific "zeros"

  1. #1
    Registered User
    Join Date
    11-20-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Microsoft 2007
    Posts
    17

    Average Formula that excludes specific "zeros"

    Microsoft Excel 2007

    All,

    I am trying to determine the average movement over a 12 month span. The unique piece is that I want to exclude any month at the beginning or end of the span that has zero movement.

    The months containing the following movement are in cells C2 through N2.

    C2- 0
    D2- 0
    E2- 10
    F2- 15
    G2- 0
    H2- 8
    I2- 12
    J2- 0
    K2- 10
    L2- 2
    M2- 0
    N2- 0

    In this example, I want the average formula to ignore the zeros in cells C2, D2, M2, and N2. This is because the specific items I am calculating the averages for may have been added or discontinued at any point in the year. That being said, I do want the zeros in cells G2 and J2 included in the average calculation.

    Any help is greatly appreciated.

  2. #2
    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,933

    Re: Average Formula that excludes specific "zeros"

    There is probably a much better way to do this (I will look more), but this works using a helper row...
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    M
    N
    O
    1
    C2 D2 E2 F2 G2 H2 I2 J2 K2 L2 M2 N2
    2
    0
    0
    10
    15
    0
    8
    12
    0
    10
    2
    0
    0
    3
    10
    15
    0
    8
    12
    0
    10
    2
    7.125

    C3=IF(OR(AND(C2=0,D2=0),AND(B2=0,C2=0)),"",C2)
    copied across
    O3=AVERAGE(C3:N3)
    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

  3. #3
    Registered User
    Join Date
    11-20-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Microsoft 2007
    Posts
    17

    Re: Average Formula that excludes specific "zeros"

    FDibbins,

    One thing I noticed with this formula is that when I have a row with two 0's back-to-back they are left blank regardless of whether they are inside of other numbers or not.

    For instance, if the span goes 0,0,0,420,26,12,8,16,0,0,380,87,6 then the 1st three 0's are left blank as well as the two 0's between 16 and 380. I am hoping to keep the zeros between 16 and 380.

    Any help is appreciated.
    Last edited by The Man With No Name; 09-23-2015 at 08:08 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Average Formula that excludes specific "zeros"

    Try in C3 and copy across


    =IF(SUM($C2:C2)=0,"",IF(SUM(C2:$N$2)=0,"",C2))
    Last edited by JohnTopley; 09-23-2015 at 09:06 AM.

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

    Re: Average Formula that excludes specific "zeros"

    UDF taking averages excluding end 0 cells.Middle 0's are taken for calculation.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-20-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Microsoft 2007
    Posts
    17

    Re: Average Formula that excludes specific "zeros"

    Quote Originally Posted by JohnTopley View Post
    Try in C3 and copy across


    =IF(SUM($C2:C2)=0,"",IF(SUM(C2:$N$2)=0,"",C2))
    JohnTopley,

    Thank you so much. This is a very clean formula and appears to work exactly how I need it to.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Average Formula that excludes specific "zeros"

    Thank you for the feedback.

    Can you mark the thread as SOLVED ("Thread Tools" at top of first post)

  8. #8
    Registered User
    Join Date
    11-20-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Microsoft 2007
    Posts
    17

    Re: Average Formula that excludes specific "zeros"

    Quote Originally Posted by JohnTopley View Post
    Thank you for the feedback.

    Can you mark the thread as SOLVED ("Thread Tools" at top of first post)
    Thanks. I was just coming back to do that.

+ 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. Replies: 7
    Last Post: 06-29-2015, 11:44 AM
  2. EXCEL 2003 - Need an "AVERAGEIF" formula to exclude "0" in average
    By kerry0507 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-18-2015, 03:37 PM
  3. [SOLVED] :confused: Auto pick "specific data" and put it in "specific cells" with date
    By pipsmultan in forum Excel Formulas & Functions
    Replies: 29
    Last Post: 08-27-2014, 03:31 AM
  4. Auto Pick Only "Specific Day & Date" & put in "specific cells" Vertically
    By pipsmultan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2014, 01:24 AM
  5. [SOLVED] How can I copy "=Average(A1:A2)" and paste as "=Average(A3:A4)" in next space in column?
    By matt_m_is_me in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-27-2014, 11:02 AM
  6. [SOLVED] Changing zeros in a worksheet to their "column" "Row 1" value
    By markthehousebuyer in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-12-2013, 10:23 PM
  7. Formula that excludes cells if next column reads "away"
    By mr63249 in forum Excel - New Users/Basics
    Replies: 9
    Last Post: 11-23-2008, 10:53 PM

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