I did provide the correct formula. In fact I got it
from someone here.
=AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-1,,-14))
That does not make it right. As the OFFSET help page states: "Height
must be a positive
number".
However, I always warn people that we cannot trust MS documentation.
It is likely that the support of negative height is an
intentional feature. Nevertheless, I try to avoid undocumented
features if it is just as easy not to rely on them. So I would use
the following formula:
=AVERAGE(OFFSET($AH$14,COUNT($AH14:$AH5001)-14,,14))
Example:
A B
4
6
3 O/A
2
5
4 O/A
2
The current formula averages the last 14 days regardless
of what is in column B. What I want to do now is average
the last 14 days unless an O/A appears in column B. In
that case it would skip (or throw out) that line as if it
didn't exist.
Perhaps the following __array_formula__ [*]:
=AVERAGE(IF(OFFSET($B$14,COUNT($A14:$A5001)-14,,14))<>"o/a",
OFFSET($A$14,COUNT($A14:$A5001)-14,,14)))
[*] Enter an array formula by pressing ctrl+shift+Enter instead of
Enter. Excel will display an array formula surrounded by curly braces
in the Formula Bar, i.e. {=formula}. You cannot type the curly braces
yourself. If you make a mistake, select the cell, press F2 and edit,
then press ctrl+shift+Enter.
But your requirements are ambiguously, IMHO.
That formula takes the last 14 non-empty cells in A14:A5001 and
excludes from the average any cells in those 14 that have "O/A" in the
corresponding cell in column B. So you might average fewer than 14
cells.
(In fact, you might average zero cells, in which case that formula
returns an Excel error. If you need help to avoid that error, the
ease of doing so depends on the version of Excel you are using. Which
one?)
That formula does __not__ average the last 14 non-empty cells in
A14:A5001 that do not have "O/A" in the corresponding cell in column
B. In other words, it does __not__ ensure that you average exactly 14
cells.
Which do you require?
To be clear, here is one that you might present your expectations
unambiguously.
Suppose A14:A100 contains numbers. The last 14 non-empty cells are
A87:A100. Suppose that only B88 and B95 contain "O/A".
Do you want effectively AVERAGE(A87,A89:A94,A96:A100)?
Or do you want effectively AVERAGE(A85:A87,A89:A94,A96:A100)?
The latter extends the "range" of cells to be averaged upward to
compensate for the cells that are ignored because of "O/A" in column
B. That is hard, IMHO.