Lookup Formula

BradleyS

Active Member
Joined
Oct 28, 2006
Messages
351
Office Version
  1. 2010
Platform
  1. Windows
Hi Marcelo Branco gave me some help with a formula as shhown below:

Array-Formula in G3
=LOOKUP(REPT("z",255),CHOOSE({1,2},"",INDEX($D$2:$D$13,MATCH(1,IF($A$2:$A$13=$F3,IF(ISNUMBER(SEARCH(G$2,$C$2:$C$13)),1))))))

Which works very well in this table:
Excel Workbook
ABCDEFGHI
1IDDATECODEDESCBLUEORANGERED
2113/11/2001C100112TEXT2IDC1021263009h4
38509/01/2009C10..00TEXT11TEXT2
422721/07/1993C100112TEXT285TEXT1
527605/02/2007C10..00TEXT1227TEXT2
627821/02/2008C10..00TEXT1276TEXT1
727821/02/20082126300TEXT3278TEXT1TEXT3
828318/08/20082126300TEXT3283TEXT3
928826/02/1998C100112TEXT2288TEXT2
10204918/05/20119h43.00TEXT52049TEXT6TEXT5
11204921/06/2011C10E600TEXT61906TEXT7TEXT4
12190610/10/20109h4..00TEXT4
13190611/08/2009C109.12TEXT7
Sheet2
Excel 2003
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.

What I would like to do now is show the Dates in column B under each of the Blue, Orange and Red columns, instead of showing the DESC.

Please could someone help me change the code to make this work?

I thought it would be easy but I was very wrong!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I think I should also explain:

It needs to match the id's in both tables
Then if the code is the same as what is under BLUE, ORANGE or RED it should display the date this time around.
Instead of the text desc which it is currently set up to do.
 
Upvote 0
I can now see that I need to change the INDEX to column B to show the date instead of the text in column D.

Array formula:
=LOOKUP(REPT("z",255),CHOOSE({1,2},"",INDEX($B$2:$B$13,MATCH(1,IF($A$2:$A$13=$F3,IF(ISNUMBER(SEARCH(G$2,$C$2:$C$13)),1))))))

However, the date will not show and I don't know why, could someone tell me what I'm missing?
 
Upvote 0
OK I think it's the REPT function causing the problem as it only uses text values.

When I'm now looking at a date value, therefore what can I use it in place?
 
Upvote 0
I can now see that I need to change the INDEX to column B to show the date instead of the text in column D.

Array formula:
=LOOKUP(REPT("z",255),CHOOSE({1,2},"",INDEX($B$2:$B$13,MATCH(1,IF($A$2:$A$13=$F3,IF(ISNUMBER(SEARCH(G$2,$C$2:$C$13)),1))))))

However, the date will not show and I don't know why, could someone tell me what I'm missing?

When a numeric value is expected..., modify it to:

=LOOKUP(9.99999999999999E+307,CHOOSE({1,2},0,INDEX($B$2:$B$13,MATCH(1,IF($A$2:$A$13=$F3,IF(ISNUMBER(SEARCH(G$2,$C$2:$C$13)),1))))))

which must be confirmed with control+shift+enter, not just enter.

Moreover, you'll need to custom format the formula cell as e.g.:

[=0]"";d/m/yyyy
 
Upvote 0
That's perfect thank you.

However, can I not just format the cells using Date, what does [=0]"";d/m/yyyy do?
 
Upvote 0
That's perfect thank you.

You are welcome.

However, can I not just format the cells using Date, what does [=0]"";d/m/yyyy do?[/QUOTE]

The formula returns a 0 ("" is imppossible) when no match is found. A regular date formatting would display cells with 0 outcome as: 1/0/1900.

[=0]"";d/m/yyyy allows to display them as if they are blank.
 
Upvote 0
Ah I see.

However, when no match is found I get an #N/A not a zero value
 
Upvote 0
My fault I just found another change in your code from "" to 0, which now makes perfect sence.

Thank you very much
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

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