IF THEN statement with nested VLOOKUPs not working

Old_Dog

New member
Joined
Apr 29, 2025
Messages
2
Reaction score
0
Points
1
Excel Version(s)
365
I have the following formula in column be (see below) and individually each section works and returns what is expected but when combined it fails on the last portion.

=IF(AND(H7="",I7=""),"Voluntary",IF(H7<>"",VLOOKUP(H7,Reason_Code,2,VLOOKUP(I7,Manual_Reason,2,FALSE))))

Here are the individual formulas I started with and each returned the correct results.
=IF(AND(H2="",I2=""),"Voluntary",FALSE)
=IF(H3<>"",VLOOKUP(H3,Reason_Code,2,FALSE))
=VLOOKUP(I4,Manual_Reason,2,FALSE)

I combined the first two using the second one as the FALSE statement with no issue.
=IF(AND(H5="",I5=""),"Voluntary",IF(H5<>"",VLOOKUP(H5,Reason_Code,2,FALSE)))

When I added the last statement it just returned FALSE. The first three lines in the snippet are the results of each individual formula. Line 4 & 5 is the combination of the first two formulas to show it works for either scenario. Line 6 is where I added the last formula and then it fails...and yes the Term Reason "Resignation" is in the range name.
1745945361845.png
1745945794940.png

Can anyone see what's causing the issue? I've nested lots of VLOOKUPs in IF THEN statements and never had this issue.
 
Answer found using ChatGPT. I was replacing the second FALSE statement with the last VLOOKUP and that was causing the issue.

Original code
=IF(AND(H7="",I7=""),"Voluntary",IF(H7<>"",VLOOKUP(H7,Reason_Code,2,VLOOKUP(I7,Manual_Reason,2,FALSE))))

Corrected code
=IF(AND(H7="",I7=""),"Voluntary",IF(H7<>"",VLOOKUP(H7,Reason_Code,2,FALSE),VLOOKUP(I7,Manual_Reason,2,FALSE)))
 
For future reference, you'll get better help if you post a sample workbook, not pictures.

Also, these are FORMULAE, not code.

The FALSE (or 0) at the end of a VLOOKUP tells Excel to look for an exact match. TRUE (or 1) tells it to look for an approximate match.
 
Back
Top