Quite often I end up including the same calculation in a formula twice, like this:
=if(iserror(vlookup("lookup",SheetX!A2:X350,5,false)),"",vlookup("lookup",SheetX!A2:X350,5,false))
I'd like to remove the duplication without cluttering my sheet with endless hidden columns. Is there some way to embed a subclause in a formula? Something like this?
=if(iserror(myLookup),"",myLookup)
where
myLookup = vlookup("lookup",SheetX!A2:X350,5,false)
Best Answer
A match is going to be found for
lookup
or it is not going to be found so two vlookups are not necessary. In general what you seek is not possible, though where you want a response to be the result of one ‘clause’ or a different responses where that ‘clause’ returns an error there is the option of theiferror
function. So your formula might be rewritten, and shortened: