Simplify VLOOKUP and IF Formula?

jeffcoleky

Active Member
Joined
May 24, 2011
Messages
274
I created the formula below that does the following: Display "Yes" if the address is For Sale, and if not, check to see if it's Vacant, and if so display "TRUE". Otherwise leave cell empty. I even have a working formula...

Here's my sample data:

Excel 2010
ABCDE
1DATAVacant(normally in another workbook)For Sale
(normally in another Sheet)
2111 main stTRUEYes
3222 smith rdFALSEYes
4333 sammy rdTRUE
5678 Ninth StFALSENo
6
7LOOKUPSVacant LookupFor Sale LookupCurrent Formula
8111 main stTRUEYesYes
9222 smith rdFALSEYesYes
10333 sammy rdTRUE0TRUE
11555 Notfoundabove Rd#N/A#N/A

<tbody>
</tbody>
Sheet1

B8 Formula:
Code:
=VLOOKUP($A8,A$2:C$5,2,FALSE)
C8 Formula:
Code:
=VLOOKUP($A8,A$2:C$5,3,FALSE)
E8 Formula, (desired result) is working when combined with the other two formulas:
Code:
=IF(ISNA(C8),IF(ISNA(B8),"",IF(C8="Yes",C8,IF(B8="TRUE","TRUE",""))),IF(C8=0,IF(B8=0,"",B8),C8))

My formulas in C8:C11 are working! However, my problem is that my ACTUAL data doesn't look this clean. My actual data doesn't have the Lookup fields in B8:C11. It looks more like A2:C5 + A8:A11. I need help to COMBINE my formula in E8 with the formulas in B8 & C8.

Doing so the only way I know how to, looks like this:
Code:
=IF(ISNA(VLOOKUP($A8,A$2:C$5,3,FALSE)),IF(ISNA(VLOOKUP($A8,A$2:C$5,2,FALSE)),"",IF(VLOOKUP($A8,A$2:C$5,3,FALSE)="Yes",VLOOKUP($A8,A$2:C$5,3,FALSE),IF(VLOOKUP($A8,A$2:C$5,2,FALSE)="TRUE","TRUE",""))),IF(VLOOKUP($A8,A$2:C$5,3,FALSE)=0,IF(VLOOKUP($A8,A$2:C$5,2,FALSE)=0,"",VLOOKUP($A8,A$2:C$5,2,FALSE)),VLOOKUP($A8,A$2:C$5,3,FALSE)))

Is there a shorter way to write this formula?

With my actual data, the values I'm looking up using VLOOKUP, are actually located in other workbooks too! So the above formula, combined with all the paths, filenames, etc. makes this thing look like a monster formula!

I've spent HOURS trying to shorten this formula today, but with no success.. Can anyone help?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Does this work?

=IFERROR(IF(VLOOKUP($A8,A$2:C$5,3,FALSE)="Yes","Yes",IF(VLOOKUP($A8,A$2:C$5,2,FALSE)=TRUE,TRUE,"")),"")
 
Upvote 0
I LOVE how short it is. However, i'd like it to ONLY display results if "Yes" or "TRUE". For instance, if C2="No" and B2="TRUE", i'd want it to display "TRUE". Any idea how to add that to your formula?

Edit: I just noticed my original formula didn't take that into account either.
 
Last edited:
Upvote 0
As far as I know it already works that way. Did you test it on that example and get different results?
 
Upvote 0
Strange, I did test it before my previous post. However, I double checked and it worked.... :) I don't know what i did wrong the fist time incorrectly but I believe you got it. Thank you!!!
 
Upvote 0
Ben, I'll gladly start a new thread if necessary, but I just realized something about my data that I was unclear about above, and that situation breaks the formula.

My data in A2:B5 is actually located in two different locations. Here's how i should have written the example above:


Excel 2010
ABCDE
1DATAFor Sale (normally in another Sheet)
2111 main stYes
3222 smith rdYes
4333 sammy rd
5678 Ninth StNo
6
7LOOKUPSVacant LookupFor Sale LookupCurrent Formula
8111 main stTRUEYesYes
9222 smith rdTRUEYesYes
10333 sammy rdTRUE0TRUE
11555 Notfoundabove Rd#N/A#N/A
12
13DATAVacant (normally in another workbook)
14111 main stTRUE
15222 smith rdTRUE
16333 sammy rdTRUE
17678 Ninth StFALSE
Sheet1


Basically the vacant section moved down....

Here's how I modified your formula to adapt:
Code:
=IFERROR(IF(VLOOKUP($A8,A$2:C$5,3,FALSE)="Yes","Yes",IF(VLOOKUP($A8,A$14:B$17,2,FALSE)=TRUE,TRUE,"")),"")

The formula breaks when the formula cannot lookup an address in the A2:A5 range. In that situation it ignores the address found in A14:A17.

Do you have any ideas how it could be adapted or should I start a new thread for this?
 
Upvote 0
Your formula looks good to me. What do you mean by "breaks when the formula cannot lookup an address in the A2:A5 range?"

In your example, it seems to be working, otherwise 333 Sammy Rd would be blank. Whereas you are returning TRUE.
 
Upvote 0
I didn't realize the two tables were different lists, I thought they contained the same addresses, but one had the On Sale column, and the other contained the Vacant column.

I'll take another stab at it later.
 
Upvote 0

Forum statistics

Threads
1,216,102
Messages
6,128,849
Members
449,471
Latest member
lachbee

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