+ Reply to Thread
Results 1 to 6 of 6

averaging only certain rows within a range

  1. #1
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    averaging only certain rows within a range

    I've been working with several formulas to get an average of certain rows, based on values in a column, but I'm getting #DIV/0 errors.

    The average range depends on a number in another column, and it must only average positive numbers.

    I've attached a spreadsheet with a note showing what I'd like.

    It seems like a simple formula, but I'm just not experienced enough to get it to work. If it helps I can post the formula I've been trying.

    Thanks to all you bright people helping me!
    Attached Files Attached Files

  2. #2
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: averaging only certain rows within a range

    In cell R19

    =IF(M19=0,0,AVERAGEIF(M$9:M19,"<>0"))

    Copy down
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  3. #3
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: averaging only certain rows within a range

    Thanks. If I do that, then the calculations are correct for cells R19 through R24, however R25 should be $24.73, and R26 should be $33.29. (The formula is returning values of $28.71 for R25 and $37.96 for R26)

    The average range needs to be dynamic somehow. Since cell Q24 is 0, it means no shares are owned at that point. So the average should start over begining at row 25 and not include any rows above. What we want in column R, is the average price of shares currently owned. Any thoughts? Thanks much!

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: averaging only certain rows within a range

    jrtaylor,

    I don't understand how
    and R26 should be $33.29.
    If I have been understanding where the resets occur formula should be averaging M25:M26 in R26, or $24.73 and $75.38. I get $50.05 in R26 with this array entered formula in R9 filled down. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    What am I missing?
    Dave

  5. #5
    Forum Contributor
    Join Date
    12-03-2008
    Location
    Key West, FL
    MS-Off Ver
    365 Apps for Enterprise
    Posts
    665

    Re: averaging only certain rows within a range

    Thanks. What you were missing was my failure to do the math right! Your formula solves the problem.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: averaging only certain rows within a range

    You're welcome. Glad to hear it works. Thanks for the feedback and the rep.

+ 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. Averaging last 3 rows of data using VBA
    By eclairez7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2016, 10:53 AM
  2. [SOLVED] Averaging every 10 rows
    By bombpop in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-04-2014, 01:20 PM
  3. [SOLVED] Averaging every 24 rows
    By Mroy in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-17-2013, 06:01 AM
  4. Averaging a Range
    By NewToVBA_23 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2013, 05:51 PM
  5. [SOLVED] Averaging across several rows
    By Mith in forum Excel General
    Replies: 4
    Last Post: 05-21-2012, 03:25 AM
  6. Averaging values in different rows
    By pittopitto in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-21-2007, 10:46 PM
  7. Help - Averaging multiple rows
    By milinado in forum Excel General
    Replies: 1
    Last Post: 10-27-2006, 04:45 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