MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Sep 3rd, 2003, 01:17 PM   #1
dontgetit
 
Join Date: Apr 2003
Posts: 67
Default Rid the N/A# in vlookup

Good day

Can someone please tell me what I have to add to a Vlookup formula to have it bring back a 0 or blank cell instead of N/A# when there is no result.

Please help !

Thanks
dontgetit is offline   Reply With Quote
Old Sep 3rd, 2003, 01:23 PM   #2
masim
 
Join Date: Jun 2003
Location: Pakistan
Posts: 130
Default Re: Rid the N/A# in vlookup

Manipulate the vlookup part of the following formula to adjust to your requirements

=IF(ISNA(VLOOKUP(A6,$A$1:$B$2,2,0)),0,(VLOOKUP(A6,$A$1:$B$2,2,0)))


I hope this would help

Regards
Asim
masim is offline   Reply With Quote
Old Sep 3rd, 2003, 01:32 PM   #3
rwilding
 
Join Date: Jul 2003
Posts: 103
Default Re: Rid the N/A# in vlookup

What I have done is put in a simple IF statement, so that if B8 (the cell that has the data you are comparing with) is blank the VLOOKUP cell will be blank, otherwise perform the VLOOKUP.

=IF(B8="","",VLOOKUP(B8,$K$2:$L$3130,2,0))


Hope this helps,
Richard
rwilding is offline   Reply With Quote
Old Sep 3rd, 2003, 01:38 PM   #4
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 39,499
Default Re: Rid the N/A# in vlookup

A couple of options in order of efficiency and beauty...

1] Use an additional cell:

In B1 enter:

=VLOOKUP(LookupValue,LookupTable,ColIdx,0)

In A1 enter:

=IF(ISNA(B1),0,B1)

2] Download & install the free morefunc.xll add-in & use:

=IF(ISNA(SETV(VLOOKUP(LookupValue,LookupTable,ColIdx,0))),0,GETV())

which is as efficient as Option 1.

3] If Option 2 is not feasible, add the following code to your workbook as a module:

Public Function V(Optional vrnt As Variant) As Variant
'
' Stephen Dunn
' 2002-09-12
'
Static vrntV As Variant
If Not IsMissing(vrnt) Then vrntV = vrnt
V = vrntV
End Function

and use:

=IF(ISNA(V(VLOOKUP(LookupValue,LookupTable,ColIdx,0))),0,V())

4] If efficiency is not important to you, use either

=IF(ISNUMBER(MATCH(LookupValue,INDEX(LookupTable,0,1),0)),VLOOKUP(LookupValue,LookupTable,ColIdx,0),0)

or

=IF(ISNA(VLOOKUP(LookupValue,LookupTable,ColIdx,0)),0,VLOOKUP(LookupValue,LookupTable,ColIdx,0))

5] Reject using either senseless

=IF(ISERROR(VLOOKUP(LookupValue,LookupTable,ColIdx,0)),0,VLOOKUP(LookupValue,LookupTable,ColIdx,0))

or inefficient

=IF(COUNTIF(LookupValue,INDEX(LookupTable,0,1)),VLOOKUP(LookupValue,LookupTable,ColIdx,0),0)
Aladin Akyurek is offline   Reply With Quote
Old Sep 4th, 2003, 02:39 AM   #5
dontgetit
 
Join Date: Apr 2003
Posts: 67
Default Re: Rid the N/A# in vlookup

Thanks everyone for your reponses. I was able to use a couple of thses formulas to get the results I needed.
dontgetit is offline   Reply With Quote
Old Apr 27th, 2006, 08:14 PM   #6
joep
 
Join Date: Dec 2005
Posts: 11
Default

Many thanks the ISNA function works wonderfully!
joep is offline   Reply With Quote
Old Sep 23rd, 2009, 02:28 AM   #7
wayneooo
 
Join Date: Sep 2009
Posts: 13
Default Re: Rid the N/A# in vlookup

Hi there.

I have a similar problem, though my VLOOKUP formula is more complex, i've been unable to surpress the #VALUE! error using your suggestions. Can anybody advise?

My formula:

=VLOOKUP($A2,IF($B2>=(FROM_DATES),IF(Sheet1!$B2<=(TO_DATES),FULL_TABLE,""),""),5,FALSE)

The lookup works fine. However if no match, it returns #VALUE!. I want it to simply stay blank.

Any help appreciated.

Thanks
wayneooo is offline   Reply With Quote
Old Sep 23rd, 2009, 03:18 AM   #8
c_m_s_jr
 
Join Date: Mar 2009
Location: St. Louis, MO
Posts: 980
Default Re: Rid the N/A# in vlookup

Wayneooo maybe if you gave some sample data and explained what your trying to do with your formula a solution can be found.
__________________
You REALLY can learn something new every day, and without even trying.

Excel 2007 Windows Vista
c_m_s_jr is offline   Reply With Quote
Old Sep 23rd, 2009, 11:51 AM   #9
wayneooo
 
Join Date: Sep 2009
Posts: 13
Default Re: Rid the N/A# in vlookup

After entering the date and selecting a complaint from dropdown box in cell C, the lookup formulas in cells D and F check a table on 'Stuff' sheet which contains upto two questions asked for specific complaints and date ranges. If a match is found, the questions are returned to Sheet1 cells D and F respectively.

There can be multiple date ranges for a single complaint point. Sometimes one question is asked, sometimes two. Only one date range will apply though.

The lookup function as it stands works fine, i just want to surpress #VALUE! when no match is found, and also perhaps surpress the 0 when cell E on sheet Stuff is empty (this implies only one question is asked - the formula in Sheet1 cell D will return the first question, but as no second question, the formula in Sheet1 cell E will return '0').

The sample data here contains examples of three outcomes:

a) (ROW 1) - Lookup successful. One matching question found. No second question, so '0' is returned. I want it to be blank instead of 0.

b) (ROW 2) - Lookup unsuccessful. No matches found. Both cells return #VALUE!. I want it to be blank instead of #VALUE!.

c) (ROW 3) - Lookup successful. Two matching questions found.

Sheet1


ABCDEFG
101/05/20006OptionalIs there evidence on TDR system?
0
201/05/20008Nothing explained#VALUE!
#VALUE!
301/05/20007CostsIs there evidence in on TDR system?NoIs there evidence in on MD5?No

Spreadsheet Formulas
CellFormula
B1=VLOOKUP($C1,complaints_full, 2, FALSE)
D1=VLOOKUP($B1,IF($A1>=(FROM_DATES),IF(Sheet1!$A1<=(TO_DATES),FULL_TABLE,""),""),4,FALSE)
F1=VLOOKUP($B1,IF($A1>=(FROM_DATES),IF(Sheet1!$A1<=(TO_DATES),FULL_TABLE,""),""),5,FALSE)
A2=IF(A1="","",A1)
B2=VLOOKUP($C2,complaints_full, 2, FALSE)
D2=VLOOKUP($B2,IF($A2>=(FROM_DATES),IF(Sheet1!$A2<=(TO_DATES),FULL_TABLE,""),""),4,FALSE)
F2=VLOOKUP($B2,IF($A2>=(FROM_DATES),IF(Sheet1!$A2<=(TO_DATES),FULL_TABLE,""),""),5,FALSE)
A3=IF(A2="","",A2)
B3=VLOOKUP($C3,complaints_full, 2, FALSE)
D3=VLOOKUP($B3,IF($A3>=(FROM_DATES),IF(Sheet1!$A3<=(TO_DATES),FULL_TABLE,""),""),4,FALSE)
F3=VLOOKUP($B3,IF($A3>=(FROM_DATES),IF(Sheet1!$A3<=(TO_DATES),FULL_TABLE,""),""),5,FALSE)


Excel tables to the web >> Excel Jeanie HTML 4

NAMED RANGES

FULL_TABLE:

Stuff


ABCDE
1601/01/200001/06/2000Is there evidence on TDR system?
2820/01/200318/09/2003Does customer provide details?
3701/03/200001/06/2001Is there evidence in on TDR system?Is there evidence in on MD5?
4706/01/200509/02/2009Is evidence consistent with LPR and TSI?


Excel tables to the web >> Excel Jeanie HTML 4

FROM_DATES:

Stuff


B
101/01/2000
220/01/2003
301/03/2000
406/01/2005


Excel tables to the web >> Excel Jeanie HTML 4

TO_DATES:

Stuff


C
101/06/2000
218/09/2003
301/06/2001
409/02/2009


Excel tables to the web >> Excel Jeanie HTML 4





Stuff


ABCDE
1201/01/200001/06/2000Is there evidence on TDR system?
2420/01/200318/09/2003Does the request conflict on notes?
3701/01/200503/12/2005Is there evidence in on TDR system?Is there evidence in on MD5?
4706/01/200509/02/2009Is evidence consistent with LPR and TSI?


Excel tables to the web >> Excel Jeanie HTML 4

Last edited by wayneooo; Sep 23rd, 2009 at 12:00 PM. Reason: Minor correction
wayneooo is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 12:51 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.