Need help with ISNA

instanceoftime

Board Regular
Joined
Mar 23, 2011
Messages
102
I would like to program a macro (actually include in current marco) to do the following.

The following code searches a master file looking for associated prices. However there is a possibility that A1 doesn't contain the number looked for.
This gives me the #NA error in the cell. I would like to go down column E and change the #NA to zero.

Code:
Sub pricing()
'
' pricing Macro
'
' Keyboard Shortcut: Ctrl+u
'


Dim lr As Long




    lr = Cells(Rows.Count, "A").End(xlUp).Row  
    
    Range("E1:E" & lr).Formula = "=VLOOKUP(A1,[final.xls]Items!$A$1:$H$40000,8,0)"[COLOR=#ff0000] 'this fetches price from a different workbook and places value in column E in the current workbook[/COLOR]


    [COLOR=#ff0000]'I want to go down column E and change [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=NA]#NA[/URL]  to zero[/COLOR]


End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I would like to program a macro (actually include in current marco) to do the following.

The following code searches a master file looking for associated prices. However there is a possibility that A1 doesn't contain the number looked for.
This gives me the #NA error in the cell. I would like to go down column E and change the #NA to zero.

Code:
Sub pricing()
'
' pricing Macro
'
' Keyboard Shortcut: Ctrl+u
'


Dim lr As Long




    lr = Cells(Rows.Count, "A").End(xlUp).Row  
    
    Range("E1:E" & lr).Formula = "=VLOOKUP(A1,[final.xls]Items!$A$1:$H$40000,8,0)"[COLOR=#ff0000] 'this fetches price from a different workbook and places value in column E in the current workbook[/COLOR]


    [COLOR=#ff0000]'I want to go down column E and change [URL="https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=NA"]#NA[/URL]  to zero[/COLOR]


End Sub


Why don't you just use "IFERROR"? (See mod in blue.)

Code:
Range("E1:E" & lr).Formula = "=[COLOR=#0000ff]IFERROR([/COLOR]VLOOKUP(A1,[final.xls]Items!$A$1:$H$40000,8,0)[COLOR=#0000ff],0)[/COLOR]"[COLOR=#ff0000] 'this fetches price from a different workbook and places value in column E in the current workbook
[/COLOR]

HTH
 
Upvote 0
awesome, I was looking into how to wrap it in IFERROR as well but both are beyond me. Thanks .... Your solution worked perfect!
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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