S
Sean Cunningham
I have an array formula which finds a negative average correctly but not a
positive average for a small column of numbers
For example I have a small column containing positive and negative numbers
- formatted as percentages. Column A1:A20
I have manually filled the first 13 cells in the column with numbers and
have no gaps.
For the last 7 cells I have put in a simple formula to copy a value from
another cell if that cell has a value, otherwise to leave the cell blank.
Accordingly the last 7 cells are empty.
Now I would like to find the average of the last 2 negative numbers in the
column and the average of the last 2 positive numbers
To find the average of the last two negative numbers I entered this array
formula - into D5
=SUM(IF($A$1:$A$20<=0,IF(ROW($A$1:$A$20)*($A$1:$A$20<=0)>=LARGE(ROW($A$1:$A$20)*($A$1:$A$20<=0),$C1),($A$1:$A$20),0),0))/$C1
Note $C1 equals "2" - meaning I'm looking at just the average of the last
two numbers.
Now this works just great. No problems
Getting the formula to work for positive numbers is where I have run into
difficulty
For finding the average of the last 2 positive numbers I entered the
following array formula
=SUM(IF($A$1:$A$20>0,IF(ROW($A$1:$A$20)*($A$1:$A$20>0)>=LARGE(ROW($A$1:$A$20)*($A$1:$A$20>0),$C1),($A$1:$A$20),0),0))/$C1
This returns 0% - wrong answer
However when I enter the address of just the occupied cells as in...
=SUM(IF($A$1:$A$13>0,IF(ROW($A$1:$A$13)*($A$1:$A$13>0)>=LARGE(ROW($A$1:$A$13)*($A$1:$A$13>0),$C1),($A$1:$A$13),0),0))/$C1
This gives me the right answer but means I have to manually change the
formula each time a row is filled.
How do I get the formula to work as the negative average works.
I'm using Excel 2000
Thanks for any guidance you can give
positive average for a small column of numbers
For example I have a small column containing positive and negative numbers
- formatted as percentages. Column A1:A20
I have manually filled the first 13 cells in the column with numbers and
have no gaps.
For the last 7 cells I have put in a simple formula to copy a value from
another cell if that cell has a value, otherwise to leave the cell blank.
Accordingly the last 7 cells are empty.
Now I would like to find the average of the last 2 negative numbers in the
column and the average of the last 2 positive numbers
To find the average of the last two negative numbers I entered this array
formula - into D5
=SUM(IF($A$1:$A$20<=0,IF(ROW($A$1:$A$20)*($A$1:$A$20<=0)>=LARGE(ROW($A$1:$A$20)*($A$1:$A$20<=0),$C1),($A$1:$A$20),0),0))/$C1
Note $C1 equals "2" - meaning I'm looking at just the average of the last
two numbers.
Now this works just great. No problems
Getting the formula to work for positive numbers is where I have run into
difficulty
For finding the average of the last 2 positive numbers I entered the
following array formula
=SUM(IF($A$1:$A$20>0,IF(ROW($A$1:$A$20)*($A$1:$A$20>0)>=LARGE(ROW($A$1:$A$20)*($A$1:$A$20>0),$C1),($A$1:$A$20),0),0))/$C1
This returns 0% - wrong answer
However when I enter the address of just the occupied cells as in...
=SUM(IF($A$1:$A$13>0,IF(ROW($A$1:$A$13)*($A$1:$A$13>0)>=LARGE(ROW($A$1:$A$13)*($A$1:$A$13>0),$C1),($A$1:$A$13),0),0))/$C1
This gives me the right answer but means I have to manually change the
formula each time a row is filled.
How do I get the formula to work as the negative average works.
I'm using Excel 2000
Thanks for any guidance you can give