Search code examples
excelexcel-formulapseudocode

How to convey this formula in Excel?


I've been trying to write an excel formula but have been having no luck in making it work. I can easily write the formula in pseudo code, but cannot convert it to excel!

IF (ISERROR(A) OR A == 0) {
    IF (ISERROR(B) OR B == 0) {
        return 2958465;
    } ELSE {
        return B;
    }
} ELSE {
    return A;
}

This is what I've got so far, but it doesn't work when I change A and B to their VLOOKUP formulas like I want to:

=IF(OR(ISERROR(A), A = 0),IF(OR(ISERROR(B), B = 0),2958465,B),A)

Thanks a lot!


Solution

  • I solved it with this formula:

    =IF(IFERROR(VLOOKUP([@[Serial '#]], Table4, 184, FALSE), IFERROR(VLOOKUP([@AssetTag], Table48, 184, FALSE), 2958465)) = 0, 2958465, IFERROR(VLOOKUP([@[Serial '#]], Table4, 184, FALSE), IFERROR(VLOOKUP([@AssetTag], Table48, 184, FALSE), 2958465)))

    It doesn't feel very elegant, but it works!