formula results and custom number formats

miconian

Well-known Member
Joined
Aug 18, 2004
Messages
769
I've got a cell with the following custom number formatting:

_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)

As you can see, a zero should show up as a dash with a dollar sign. Usually, with this formatting, it does.

However, this particular cell also contains this formula:

=IF(ISNA(VLOOKUP(A9,'2011 Calc (Reset)'!$H$44:$M$54,6,FALSE) = TRUE),"0",VLOOKUP(A9,'2011 Calc (Reset)'!$H$44:$M$54,6,FALSE))

Basically, if the result of the VLOOKUP is NA, the result of the overall formula should be zero.

However, when this formula gives a zero result, all the formatting goes out the window. The user sees a zero flush against the left wall of the cell.

What can I do so that, when the formula returns zero, that zero is formatted properly?

Excel 2007, Windows XP
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
When you place double-quotes around a number, it returns it as text, not numeric (double-quotes are text qualifiers). Try removing them (you don't need the "=TRUE" part either), i.e.:
Code:
=IF(ISNA(VLOOKUP(A9,'2011 Calc (Reset)'!$H$44:$M$54,6,FALSE)),0,VLOOKUP(A9,'2011 Calc (Reset)'!$H$44:$M$54,6,FALSE))
 
Upvote 0
Thanks, man. I can't believe I missed that quote issue.

As a special extra credit bonus: Do you happen to see a more efficient way to write that formula in general? I know VLOOKUPs slow down workbooks, and this one is slow, and there are, as you can see, two VLOOKUPS in this cell. And, of course, this cell actually represents hundreds of similar cells.
 
Upvote 0
Are you using Excel 2007 or later?
If so, you can get away with one VLOOKUP if you make use of the new IFERROR function.

=IFERROR(VLOOKUP(...),0)
 
Upvote 0

Forum statistics

Threads
1,224,551
Messages
6,179,476
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top