I am trying to make an excel formula which will find the maximum value in a range of a column (P) where adjacent value in Q is equal to 2 minus value adjacent to the cell with the formula. For example, if I had
p | q | r
2 | 4 | formula
3 | 6 | formula
4 | 8 | formula
5 | 8 | formula
6 | 10| formula
I would want the formula to make it
p | q | r
2 | 4 | 0
3 | 6 | 2
4 | 8 | 3
5 | 8 | 3
6 | 10| 4
Currently I have
=MAX(IF(Q:Q=(Q5-2),P$2:P5))
The numbers in Q are generated using the formula below, which counts the number of spaces in cells in a different column and is working as intended.
=FIND(LEFT(TRIM(A5),1),A5)-1