Max formula ignoring N/A values

sisco -  
 Anonymous user -
Hello everyone,

I would like to incorporate an "if error" into my formula (below) because when there is a variable set to "N/A," my Max() formula returns a "N/A" whereas I want my formula to take the highest value excluding the "N/A." For example:
A1 = 7
A2 = 2
A3 = N/A
A4 = 4
with my Max() formula, I end up with "N/A," however I would like to get "7."

Formula: =MAX(IF(AA5=3,OFFSET(INDEX(Ref.!K11:P16,MATCH(K5,Ref.!G11:G16,0),MATCH(L5,Ref.!K10:P10,0)),3,-3),IF(AA5=2,OFFSET(INDEX(Ref.!K11:P16,MATCH(K5,Ref.!G11:G16,0),MATCH(L5,Ref.!K10:P10,0)),2,-2),IF(AA5=1,OFFSET(INDEX(Ref.!K11:P16,MATCH(K5,Ref.!G11:G16,0),MATCH(L5,Ref.!K10:P10,0)),1,-1),IF(AA5=0,M5,"N/A")))),IF(AA5=3,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(S5,Ref.!K30:P30,0)),3,-3),IF(AA5=2,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(S5,Ref.!K30:P30,0)),2,-2),IF(AA5=1,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(S5,Ref.!K30:P30,0)),1,-1),IF(AA5=0,T5,"N/A")))),IF(AA5=3,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(V5,Ref.!K30:P30,0)),3,-3),IF(AA5=2,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(V5,Ref.!K30:P30,0)),2,-2),IF(AA5=1,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(V5,Ref.!K30:P30,0)),1,-1),IF(AA5=0,W5,"N/A")))),IF(AA5=3,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(P5,Ref.!K30:P30,0)),3,-3),IF(AA5=2,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(P5,Ref.!K30:P30,0)),2,-2),IF(AA5=1,OFFSET(INDEX(Ref.!K31:P36,MATCH(K5,Ref.!G31:G36,0),MATCH(P5,Ref.!K30:P30,0)),1,-1),IF(AA5=0,Q5,"N/A")))))

Thank you in advance for your help.
PS: sorry for the lengthy formula, it considers several conditions and since I'm not great at VBA, I'm managing with formulas.

Configuration: Windows / Chrome 94.0.4606.81

3 answers

  1. DjiDji59430 Posted messages 4278 Registration date   Status Member Last intervention   717
     
    Hello everyone,

    Hello,
    Generally, with a "truckload" of IF(), there is surely another method to achieve the desired result.

    An EXCEL file (test or not), completed with exhaustive explanations and manually filled examples, uploaded to https://www.cjoint.com/, would allow the participants to answer your question more precisely. Also include your version of Excel.
    Best regards
    0
    1. brucine Posted messages 24810 Registration date   Status Member Last intervention   4 165
       
      Hello,

      It's true that it's unreadable; for my part, I didn't even try to understand it.

      So just a general rule that is often misunderstood: even if we "condition" N/A in the formula, we'll be stuck as soon as Excel processes it and encounters it.

      IF(AA5=0,M5,"N/A"): the N/A error results not from the fulfillment of the negative condition, but from the prior "calculation" of AA5.

      We need to prevent Excel from doing this calculation by testing N/A "at the beginning":

      IF(ISNA(AA5), etc...
      0
  2. tontong Posted messages 2575 Registration date   Status Member Last intervention   1 064
     
    Hello,
    Somewhat random proposal (without a file)
    Replace ;« N/A ») with ;-99)
    -99 is a lower bound for all values.
    If AA5 can take other values than 0, 1, 2, or 3
    =IF(OR(AA5=0;AA5=1;AA5=2;AA5=3);MAX(the modified formula)))));NA())
    0