![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Apr 2003
Posts: 67
|
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 |
|
|
|
|
|
#2 |
|
Join Date: Jun 2003
Location: Pakistan
Posts: 130
|
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 |
|
|
|
|
|
#3 |
|
Join Date: Jul 2003
Posts: 103
|
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 |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: The Hague
Posts: 39,499
|
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) |
|
|
|
|
|
#5 |
|
Join Date: Apr 2003
Posts: 67
|
Thanks everyone for your reponses. I was able to use a couple of thses formulas to get the results I needed.
|
|
|
|
|
|
#6 |
|
Join Date: Dec 2005
Posts: 11
|
Many thanks the ISNA function works wonderfully!
|
|
|
|
|
|
#7 |
|
Join Date: Sep 2009
Posts: 13
|
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 |
|
|
|
|
|
#8 |
|
Join Date: Mar 2009
Location: St. Louis, MO
Posts: 980
|
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 |
|
|
|
|
|
#9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Join Date: Sep 2009
Posts: 13
|
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
Excel tables to the web >> Excel Jeanie HTML 4 NAMED RANGES FULL_TABLE: Stuff
Excel tables to the web >> Excel Jeanie HTML 4 FROM_DATES: Stuff
Excel tables to the web >> Excel Jeanie HTML 4 TO_DATES: Stuff
Excel tables to the web >> Excel Jeanie HTML 4 Stuff
Excel tables to the web >> Excel Jeanie HTML 4 Last edited by wayneooo; Sep 23rd, 2009 at 12:00 PM. Reason: Minor correction |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|