Display 0 instead of #N/A

zzdave

New Member
Joined
May 21, 2002
Messages
13
I know there is a way to do this but can't for the life of me remember it. I am running a vlookup, and in some cells it quite rightly returns #N/A. However I want the cell to display 0 instead. I have tried some 'if' formulas but with no success.
Any help greatly appreciated.
David Williams
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
if(isna(vlookup(blah,blah,1,false)),0,vlookup(blah,blah,1,false))

ISNA will only omit NA errors whereas

ISERROR will omit all errors.
 
Upvote 0
If you want to do this on a large scale.... perhaps this macro will help - can't claim the credit for it but it works a dream & add IF(ISERR formulas around all formulas in a worksheet.

Code:
Sub ErrorTrapAddDDL()

' Adds =If(IsError() around formulas

  Dim cel As Range
  Dim rng As Range
  Dim Check As String

  Const Equ As String = "=IF(ISERROR(_x) ,"""", _x)"

  Check = Left$(Equ, 12) & "*" ' Check for =IF(ISERROR(

  On Error Resume Next

  Set rng = Selection.SpecialCells(xlFormulas, 23)
  If rng Is Nothing Then Exit Sub

  With WorksheetFunction
    For Each cel In rng
      If Not cel.Formula Like Check Then
        cel.Formula = .Substitute(Equ, "_x", Mid$(cel.Formula, 2))
      End If
    Next
  End With
End Sub

HTH
 
Upvote 0
On 2002-10-18 05:13, zzdave wrote:
I know there is a way to do this but can't for the life of me remember it. I am running a vlookup, and in some cells it quite rightly returns #N/A. However I want the cell to display 0 instead. I have tried some 'if' formulas but with no success.
Any help greatly appreciated.
David Williams

If you'd want to install the morefunc.xll add-in, downloadable from

http://longre.free.fr/english/index.html

you can use the more efficient

=IF(ISNA(SETV(VLOOKUP(lookup-value,lookup-table,columnindex,0))),"",GETV())

which avoids computing the same thing twice.
 
Upvote 0

Forum statistics

Threads
1,202,987
Messages
6,052,932
Members
444,616
Latest member
novit19089

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