Note to self

It's highly unlikely that anyone except me will find this useful. But I have to admit that sometimes I use this blog to make a note just for myself to refer back to later. Evil, I know. Anyway, if you want to know some arcane function in Excel, click on.
This:
=IF(ISERROR(VLOOKUP(F42,Sheet1!B:F,5,FALSE)),"-",VLOOKUP(F42,Sheet1!B:F,5,FALSE))
is very handy. A normal IF function looks like this:
=IF(VLOOKUP(F54,Sheet1!B:F,5,FALSE),VLOOKUP(F54,Sheet1!B:F,5,FALSE),"-")
That means:
IF the Vlookup function is true, return the result of the Vlookup, otherwise return a dash in the cell.
It looks more complicated than it is - it's simply saying if(this logical test is),(true, return this value),(false, return this value).
However, if the test returns an #N/A, you have to manually delete the cell, because it won't sum if it's in a range of cells that needs to be summed. And in a scale out, which is what I mainly use Vlookups for nowadays, that takes about a minute. A minute that I could be profitably using looking out of the window, or petting the cats. So naturally it must be eliminated.
So by inserting an ISERROR function as in
=IF(ISERROR(VLOOKUP(F42,Sheet1!B:F,5,FALSE)),"-",VLOOKUP(F42,Sheet1!B:F,5,FALSE))
You can get rid of the #N/As automatically. Magic!
Oh, no-one's reading this. Em of the future, when you search for this post next time you do a scale out: just remember that the ISERROR function will get rid of those annoying #N/As.
Comments: 4
I'm a big fan of ISNA in a similar role...
Posted by: John A-W on April 2, 2008 11:07 AM
I'm glad I write fiction, not code - though I suppose fiction is a code of its own.
And my newly posted short story takes place in a SNOWSTORM!
Posted by: Lee on April 2, 2008 03:21 PM
Or the lazy way of summing
=SUMIF(A1: A18,">#N/A")
Posted by: Crawford on April 2, 2008 11:56 PM
or leave out the dash altogether and just have "" for completely empty cell
Not at all useless - I use this sort of function all the time
Posted by: Emma H on April 3, 2008 02:09 PM