Computing.Net > Forums > Office Software > Lookup Query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Lookup Query

Reply to Message Icon

Name: Cookie79
Date: September 7, 2009 at 07:41:47 Pacific
OS: Windows XP
Product: Microsoft Excel 2007
Subcategory: Microsoft Office
Comment:

Hi there
I'm trying to do what I think should be a fairly simple lookup. I have 3 arrays, only one of which will have the data I'm looking for. I have used the following formula:
=IF(ISNA(VLOOKUP(A2,Tip,5,FALSE)),VLOOKUP(A2,KD,4,FALSE),"")
which as you can see looks in the array named "Tip" and if the information isn't there, looks in the array named "KD". I also need to look in an array called "ND" if the text from A2 isn't found in either "Tip" or "KD". Please can someone help?
Thanks
Cheryl



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: September 7, 2009 at 09:23:29 Pacific
Reply:

You didn't say what column to return for Array KH, so I chose 3.

Two ways to do it:

Note: I broke the formula apart with line feeds so they would fit in the response neatly, so you may have to put them back together when you paste them into Excel.

One says "If the VLOOKUP doesn't return #N/A for a given array, then it must be in that array."

=IF(NOT(ISNA(VLOOKUP(A2,Tip,5,0))),VLOOKUP(A2,Tip,5,0),
IF(NOT(ISNA(VLOOKUP(A2,KD,4,0))),VLOOKUP(A2,KD,4,0),
IF(NOT(ISNA(VLOOKUP(A2,KH,3,0))),VLOOKUP(A2,KH,3,0),"")))

The other says "If VLOOKUP for Array1 returns #N/A, then look in Array2. If that returns a #N/A, the look in Array 3. If that returns a #N/A, then return "". However, if Array3 didn't return a #N/A, it must be in there, similar for Array2 and Array1 working backwards through the value_if_false for each nested if.

=IF(ISNA(VLOOKUP(A2,Tip,5,0)),
IF(ISNA(VLOOKUP(A2,KD,4,0)),
IF(ISNA(VLOOKUP(A2,KH,3,0)),"",
VLOOKUP(A2,KH,3,0)),
VLOOKUP(A2,KD,4,0)),
VLOOKUP(A2,Tip,5,0))

The NOT formula is a little longer, but it's more straightforward since it just works it's way through the 3 arrays until it finds the lookup_value - or not.


1

Response Number 2
Name: Cookie79
Date: September 7, 2009 at 23:53:28 Pacific
Reply:

Absolutely fantastic! For some reason the second one won't return the value if it's in tip, but the first one works perfectly. You are a star DerbyDad03, thank you very much.


0

Response Number 3
Name: DerbyDad03
Date: September 8, 2009 at 08:53:06 Pacific
Reply:

Glad I could help.

BTW...

I pasted the 2nd formula directly from my response into a new spreadsheet - didn't even take out the line feeds - then created the named ranges and it found the lookup_value in all three ranges.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Lookup Query

Access Dropdown forms www.computing.net/answers/office/access-dropdown-forms/5509.html

Access Combo Query Filter www.computing.net/answers/office/access-combo-query-filter/3687.html

MS Access Querying.. www.computing.net/answers/office/ms-access-querying/1742.html