Matching First Letter of Cell to a Fixed Array Set

dwgnome

Active Member
Joined
Dec 18, 2005
Messages
441
Hi,

Trying to get the following to work:

=LOOKUP(LEFT(B69,1),{"T","J","N","C","P"},{"Travel","Journalism","Nature","Creative","Pictorial"})

B69 contains TM, so the answer should be "Travel", but the formula above results in "Pictorial". The lookup cell will always have two letter codes (i.e., TM, TB, TI, PB, PI etc.).

Excel 2003,

Any suggestions?

Thanks,
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
=INDEX({"Travel","Journalism","Nature","Creative","Pictorial"}, MATCH(LEFT(B69), {"T","J","N","C","P"}, 0))

or

=INDEX({"Travel","Journalism","Nature","Creative","Pictorial"}, FIND(LEFT(B69), "TJNCP"))
 
Last edited:
Upvote 0
With LOOKUP, the first array has to be sorted ascending.
Try
=LOOKUP(LEFT(B69,1),{"C","J","N","P","T"},{"Creative","Journalism","Nature","Pictorial","Travel"})
 
Upvote 0
Hi,

Trying to get the following to work:

=LOOKUP(LEFT(B69,1),{"T","J","N","C","P"},{"Travel","Journalism","Nature","Creative","Pictorial"})

B69 contains TM, so the answer should be "Travel", but the formula above results in "Pictorial". The lookup cell will always have two letter codes (i.e., TM, TB, TI, PB, PI etc.).

Excel 2003,

Any suggestions?

Thanks,
Try this...

Book1
BCDEF
69TMTravel_TTravel
70___JJournalism
71___NNature
72___CCreative
73___PPictorial
Sheet1

Create the 2 column table in E69:F73.

Then use this formula in C69:

=VLOOKUP(LEFT(B69),E69:F73,2,0)
 
Upvote 0
Hi all,

Thank you for the different ways to the same solution. All of the suggestions worked!:)

However, as I do not like #NA when results are not found and I like to avoid the ISERROR(formula,"",formula) approach, I modified each contributor's suggestion as follows:

From:
=INDEX({"Travel","Journalism","Nature","Creative","Pictorial"}, FIND(LEFT(B69), "TJNCP"))

to

=INDEX({"","Travel","Journalism","Nature","Creative","Pictorial",""}, FIND(LEFT(B69), " TJNCP"))

From :
=LOOKUP(LEFT(B69,1),{"C","J","N","P","T"},{"Creative","Journalism","Nature","Pictorial","Travel"})

I modifed slightly to:

=LOOKUP(LEFT(B69,1),{"","C","J","N","P","T"},{"","Creative","Journalism","Nature","Pictorial","Travel"})

From:
=VLOOKUP(LEFT(B69),E69:F73,2,0)

I modified to: =IF(ISBLANK(B69),"",VLOOKUP(LEFT(B69),$AF$12:$AG$16,2,0))
 
Upvote 0
Hi all,

Thank you for the different ways to the same solution. All of the suggestions worked!:)

However, as I do not like #NA when results are not found and I like to avoid the ISERROR(formula,"",formula) approach, I modified each contributor's suggestion as follows:

From:
=INDEX({"Travel","Journalism","Nature","Creative","Pictorial"}, FIND(LEFT(B69), "TJNCP"))

to

=INDEX({"","Travel","Journalism","Nature","Creative","Pictorial",""}, FIND(LEFT(B69), " TJNCP"))

From :
=LOOKUP(LEFT(B69,1),{"C","J","N","P","T"},{"Creative","Journalism","Nature","Pictorial","Travel"})

I modifed slightly to:

=LOOKUP(LEFT(B69,1),{"","C","J","N","P","T"},{"","Creative","Journalism","Nature","Pictorial","Travel"})

From:
=VLOOKUP(LEFT(B69),E69:F73,2,0)

I modified to: =IF(ISBLANK(B69),"",VLOOKUP(LEFT(B69),$AF$12:$AG$16,2,0))
Good deal. Thanks for the feedback! :cool:
 
Upvote 0

Forum statistics

Threads
1,215,016
Messages
6,122,700
Members
449,092
Latest member
snoom82

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