INSTR or IF Function - Picking out Specific text.strings in a Cell

Sphinx404

Board Regular
Joined
May 2, 2015
Messages
186
Office Version
  1. 365
Platform
  1. Windows
So I've run into a problem that I believe there is a solution for, however, I am not keen on how to implement the function.

In the chart below you'll notice that all of the FALSE returns highlighted are actually TRUE.

The code is as follows:

Range("AC2").Formula = "=IF(LEFT(K2,4)=LEFT(AB2,4),True,False)"

I'm pretty much just seeing if the first 4 letters of the USER DEFINED destination match the first 4 of the actual destination. What I need to be testing is: is "AA" contained in "AB".

I was told that I can use INSTR to get accurate results, but after looking at some examples, I don't see how declaring the "position" in which to start looking for a specific string like "Detroit" is going to help me.

It can't be this complicated; has to be simpler such as: IF "AB" contains "AA" then TRUE, if not FALSE

Customer ID (Z)User Defined Destination (AA)Airport Code Destination (AB)Dest. Match? (AC)
DTWDETROITDetroit, MITRUE
SLCSALT LAKE CITYSalt Lake City, UTTRUE
MSPSAINT PAULMinneapolis - St. Paul Int'lFALSE
MSPMINNEAPOLISMinneapolis - St. Paul Int'lTRUE
HNLHONOLULUHonolulu, HITRUE
SLCSALT LAKE CITY, UTSalt Lake City, UTTRUE
DTWDETROITDetroit, MITRUE
DTWDETROITDetroit, MITRUE
DTWDETROITDetroit, MITRUE
HNLHONOLULUHonolulu, HITRUE
LASLAS VEGASLas Vegas, NVTRUE
EWRNEWARKNew York - Newark, NJFALSE
DTWDETROITDetroit, MITRUE
PHXSKY HARBORPhoenix, AZ - Sky HarborFALSE
ATLATLANTAAtlanta, Hartsfield AtlantaTRUE
ATLHARTFIELDAtlanta, Hartsfield AtlantaFALSE
ATLATLANTAAtlanta, Hartsfield AtlantaTRUE
ATLATLANTAAtlanta, Hartsfield AtlantaTRUE
DTWDETROITDetroit, MITRUE
CLTCHARLOTTECharlotte, NCTRUE
EWRNEWARKNew York - Newark, NJFALSE

<tbody>
</tbody>
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
=ISNUMBER(SEARCH(AA2,AB2))

This can work, but its super restrictive. Is there a way to have it look for each word in the cell. For example... Saint Paul. Can I get it to look for Saint and Paul separately?
 
Upvote 0
Well, if I can't find things specifically then maybe I can at least reduce the number of FALSE returns I have... Using the first method from post #1 returns 751 FALSE... Using the ISNUMBER(SEARCH....) returns 530 FALSE. Of those 530, about 80% are actually true.
 
Upvote 0
The ISNUMBER is your best bet. You could even use substitute to convert things like st. first such as:

=ISNUMBER(SEARCH(B2,SUBSTITUTE(C2,"St.","Saint")))

but i would rather either convert the data first before applying the formula.
 
Upvote 0
All AIRPORT DESTINATIONS from column AB (above) are found using VLOOKUP from a static list.

I don't know how, but I wonder if I can create some sort of a function that will search in that list.

Search For: Customer ID
Where: Airport Codes

When Customer ID is found, search all possible names (i.e A300:J:300)

Do any of the possible names match the user defined "AA" column?

There is a way to do this... I will find out how... well... I'll attempt to find out how.
 
Upvote 0
I made a table(new sheet) with all airport codes

column "A" contains the airport code (ATL)

column "B" contains the actual location of the airport

in columns C:K I've input all possible user definitions and left room (columns) to add additional definitions at a later date... so essentially "C:U".

So now I need to work through the formula and I have no idea how to encapsulate everything I want to do in a single formula without running 20 different VLOOKUPS.

1. I need to VLOOKUP the Airport Code in the new sheet (AirportCodes) =VLOOKUP(Z2,AIRPORTCODES!

2. Once the Airport Code is found in the list, I need to SEARCH for the User Defined Airport Code("AA") in the AirportCodes! list columns "$C$2:$U$2001"

3. If it finds a match THEN true/false

Anyone know how to write such a formula?
 
Upvote 0

Forum statistics

Threads
1,216,100
Messages
6,128,827
Members
449,470
Latest member
Subhash Chand

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