ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   #N/A (https://www.excelbanter.com/excel-programming/274262-n.html)

raymond gahan

#N/A
 
using Vlookup function in an excel sheet, the result in some cells is #N/A.
I am writing a macro to find and process these cells but if I write "If
range("A1").value = "#N/A" I am getting an error . How can I identify these
cells in a macro.



keepITcool

#N/A
 
writing a macro is nice..

and could look like:

dim rngErrors as range
on error resume next
set rngErrors = Activesheet.Cells.Specialcells( _
xlCellTypeFormulas,xlErrors)
if rngerrors is nothing then
'ok
else
msgbox "you've got " & rngerrors.count & _
" errors on your sheet"
endif


Finding them manually is a piece of cake
(and basically is what my code does)

press F5 (goto)
click special
select formula / errors
press enter




but why not change your formulas to handle the error ?

=if(iserror(vlookup(val;range;col;false));"-";vlookup
(val;range;col;false))


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"raymond gahan" wrote:

using Vlookup function in an excel sheet, the result in some cells is
#N/A. I am writing a macro to find and process these cells but if I
write "If range("A1").value = "#N/A" I am getting an error . How can
I identify these cells in a macro.






All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com