If and Vlookup with Multiple Criteria

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
928
Office Version
  1. 365
Hi,

I have a list of data where the letters starts with the list in the table below in column Category. I need to insert a formula to return as the column "Then". I tried If and LEFT but I am not sure to cater for the long list .
Is there a way have a formula for this ? Appreciate all the help.

Table 1

Excel Workbook
BC
2CategoryThen
3RFPolice
4IPolice
5GPolice
6MOld IC
7AOld IC
8A plus any alphabetBC
9EBC
10JBC
11BBC
12CBC
13FBC
14SSingapore
15TArmy
16DummyMigration
17KBC
18LBC
19NNavy
20PPassport
21QBC
22UPassport
23XPassport
24YPassport
25ZPassport
Sheet1


Sample Data and The Correct Return Value
Excel Workbook
EF
2Sample DataReturn As
3RF1254Police
4I44775Police
5G4557Police
6M4555Old IC
7A4558Old IC
8AC11225BC
9E455578BC
10J4558BC
11B4585BC
12C55887BC
13F2554BC
14S22554Singapore
15T22554Army
16Dummy4558Migration
17K5558BC
18L55558BC
19N5558Navy
20P2255Passport
21Q55587BC
22U55587Passport
23X22554Passport
24Y5558Passport
25Z5558Passport
Sheet1
 
Hi Aladin,

Thank you very much. That worked. Appreciate your time and patience.

If it is not too much trouble, may I know how this formula actually works ?
 
Upvote 0

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi Aladin,

Thank you very much. That worked. Appreciate your time and patience.

If it is not too much trouble, may I know how this formula actually works ?

You are welcome.

Control+shift+enter, not just enter, and copy down:

=LOOKUP(9.99999999999999E+307,SEARCH("|"&IF(ISNUMBER(MID($E2,2,1)+0),$A$2:$A$24,SUBSTITUTE($A$2:$A$24," plus any alphabet","?")),"|"&$E2),$B$2:$B$24)

Here is a generic explanation for this type of formulas: https://www.mrexcel.com/forum/excel-questions/724843-there-case-sensitive-vlookup.html

The formula can be re-written in abstract terms as:

lookup(bignum,search-array,result-array)

The search-array here has an if-filter:

If the 2nd char of target string is a number, use the A2:A24 as is as search value, otherwise substitute in A2:A24 the wildcard ? for " plus an alphabet. Note that "|" is used to locate the symbols of A2:A24 at the start of target string in E2.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,216,377
Messages
6,130,261
Members
449,568
Latest member
mwl_y

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