lundi 8 juillet 2019

Need to convert excel IF AND statement into VBA

I have a long IF AND statement in excel (exceeding the limit) that i need to convert into VBA but cant get it to work.

I have two columns of text lists (C & D) that I want to determine the resulting risk level in column E.

the IF AND statement that i came up with is this for a single cell:

=IF(AND(C2="Improbable",D2="Acceptable"),"Low",IF(AND(C2="Improbable",D2="Tolerable"),"Medium",IF(AND(C2="Improbable",D2="Unacceptable"),"High",IF(AND(C2="Improbable",D2="Undesirable"),"Medium",IF(AND(C2="Possible",D2="Acceptable"),"Low",IF(AND(C2="Possible",D2="Tolerable"),"Medium",IF(AND(C2="Possible",D2="Unacceptable"),"Critical",IF(AND(C2="Possible",D2="Undesirable"),"High",IF(AND(C2="Probable",D2="Acceptable"),"Medium",IF(AND(C2="Probable",D2="Tolerable"),"HIgh",IF(AND(C2="Probable",D2="Unacceptable"),"Critical",IF(AND(C2="Possible",D2="Undesirable"),"High",""))))))))))))

and this works but there are too many IF statements for excel.

Any advice on how to convert this to VBA and for the entire column?

Aucun commentaire:

Enregistrer un commentaire