Show #N/A as zero

barney5

New Member
Joined
May 15, 2003
Messages
1
I have a large report template 'fed' from numerous tables using VLOOKUP. Whenever a table value isn't available, the value #N/A is returned in the report cell. The problem I'm having is that 1/3 of the report is populated with #N/A's. I tried to do a Find/Replace (replace #N/A with zero) but the error message displays "Microsoft Excel cannot find the data you're searching for."

I also thought of going through the report and manually changing the #N/A's to zeroes but not only is this a tedious process but if the source table changes to now include a report value that had been 'hardcoded' as zero, the report won't reflect the updated value.

Is there a way to replace the #N/A as zero in a cell without affecting VLOOKUP's intended function?

Thank you for your assistance.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
You could use the ISNA function with an IF statement:

=IF(ISNA(VLOOKUP(...),0,VLOOKUP(...))

EDIT: DOH! Too slow! Looks like texaslynn beat me to the punch!
 
Upvote 0
Same idea, with improved performance
use
=IF(ISNUMBER(MATCH(E1,$A$1:$A$10,0)),VLOOKUP(E1,$A$1:$B$10,2,0),0)

instead of
VLOOKUP(E1,$A$1:$B$10,2,0)

or a two cell approach
with a lookup formula in A1
read your data in B1 with =If(isna(a1),0,a1)

this prevents the rather slow vlookup process from repeating twice.
 
Upvote 0
or use this to replace errors by zero

Sub fix_errors()
On Error GoTo quit ' in case there are no errors
Selection.SpecialCells(xlCellTypeFormulas, 16).Select

Selection.Replace what:="*", Replacement:=0, lookat:=xlPart, _
searchorder:=xlByColumns, MatchCase:=False
Exit Sub
quit:
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,711
Messages
6,161,450
Members
451,707
Latest member
PedroMoss2268

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