+ Reply to Thread
Results 1 to 11 of 11

Average Every Second Line of an Array

  1. #1
    Registered User
    Join Date
    10-10-2014
    Location
    BC Canada
    MS-Off Ver
    2010
    Posts
    5

    Red face Average Every Second Line of an Array

    I am trying to make a function to average every second line of an area. I can get the sum function to work, but the average function assumes every empty cell is a 0, and it messes up the average. I have also tired AverageIF() but i only get errors. Any help with this would be greatly appreciated.

    This is what i have right now:

    { =AVERAGE(((IF(MOD(ROW(I$13:I$313),2)=0,I$13:I$313,"")))) }


    Thanks

    Bronson

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Average Every Second Line of an Array

    Try this array alternate:

    =AVERAGE(IF((MOD($I$13:$I$313,2)=0)*($I$13:$I$313<>""), $I$13:$I$313))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Contributor
    Join Date
    05-04-2014
    Location
    New Jersey, United States
    MS-Off Ver
    Excel 2010, 2013
    Posts
    120

    Re: Average Every Second Line of an Array

    Try this (non-array formula)

    =SUMPRODUCT(I$13:I$313*(MOD(ROW(I$13:I$313),2)=0))/INT(ROWS(I$13:I$313)/2)
    Last edited by clabulis; 10-10-2014 at 10:01 PM.

  4. #4
    Registered User
    Join Date
    10-10-2014
    Location
    BC Canada
    MS-Off Ver
    2010
    Posts
    5

    Re: Average Every Second Line of an Array

    Thanks for the help, I am still getting the Error "Value" but i will play round with these alternative equations to see if i can fix it.

    Thanks again for the help

  5. #5
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Average Every Second Line of an Array

    If the issue is really about ignoring blanks, and you're saying every second line because every other row is blank due to a design choice...

    Then how about

    =SUM(I$13:I$313)/COUNT(I$13:I$313)

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Average Every Second Line of an Array

    Quote Originally Posted by Bronson84 View Post
    but the average function assumes every empty cell is a 0, and it messes up the average.
    That's actually not true, the AVERAGE function ignores Text and Blanks.
    Maybe your blanks are not really blank.
    They might actually be 0, but you have 0's hidden through either custom formatting or Excel Options.

    If that's the case, you could do

    =AVERAGEIF(I$13:I$313,"<>0")

  7. #7
    Registered User
    Join Date
    10-10-2014
    Location
    BC Canada
    MS-Off Ver
    2010
    Posts
    5

    Re: Average Every Second Line of an Array

    Every second line does an average of the last 4 lines. so it is not blank. however i want an average of all of the values, (not including the running 4 average on every second line. Yes i believe there are hidden 0's, from when i run my array formula.

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Average Every Second Line of an Array

    Can you post a sample book?

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  9. #9
    Registered User
    Join Date
    10-10-2014
    Location
    BC Canada
    MS-Off Ver
    2010
    Posts
    5

    Re: Average Every Second Line of an Array

    Here is a copy of the workbook I am working on. Any addition help would be greatly appreciated.

    Thank you

    Bronson.
    Attached Files Attached Files

  10. #10
    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,962

    Re: Average Every Second Line of an Array

    This will work for row 23 onwards....
    =IF(C22="","",AVERAGEIF(A16:A22,"<>Ave",C16:C22))

    You can adjust that range slightly for 21, 19 etc
    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

  11. #11
    Registered User
    Join Date
    10-10-2014
    Location
    BC Canada
    MS-Off Ver
    2010
    Posts
    5

    Re: Average Every Second Line of an Array

    Awesome

    Thank you 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 Line
    By AsponeBR in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 04-15-2012, 04:46 PM
  2. [SOLVED] Average - 3 months / 6 months trend line ( array formula? )
    By ccernat in forum Excel General
    Replies: 3
    Last Post: 04-04-2012, 06:24 AM
  3. Straight Average Line on Line Chart
    By miked79 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-11-2008, 12:00 PM
  4. How to add an average line to a bar chart?
    By Dmitry in forum Excel General
    Replies: 5
    Last Post: 04-27-2006, 04:40 AM
  5. [SOLVED] How to add an average line to a bar chart?
    By Dmitry in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 04-27-2006, 04:40 AM

Tags for this Thread

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