Forum Discussion
Vlookup with If And statement
If you're using Excel 365 or Excel 2021, you can use either too of these approaches.
My preference is the first one because it doesn't rely on concatenating text:
=IFERROR(
XLOOKUP(1,
(SheetA!$H$2:$H$999=$C$4)*
(SheetA!$A$2:$A$999=$C$2)*
(SheetA!$C$2:$C$999=D4),
SheetA!$G$2:$G$999),"")
- The formula returns the matching Time from column G on SheetA, or a blank if no match is found.
If you prefer the combined-key approach, this is the corrected version:
=XLOOKUP(
$C$4&"|"&$C$2&"|"&D4,
SheetA!$H$2:$H$999&"|"&SheetA!$A$2:$A$999&"|"&SheetA!$C$2:$C$999,
SheetA!$G$2:$G$999,"")
Both formulas will return the same result. I slightly prefer the first version because it's more robust (it avoids any possibility of concatenated values accidentally matching), but I think either is a good solution for this scenario.