Excel formula: search in column by another value (LIKE) - excel

I'm having a problem in Excel, where I'm trying to search an entire column for a name (not necessarily 100% identical) that is in another column.
The following table for a better explanation:
---------------------------------------
NAME CITY FATHER NAME
---------------------------------------
Saad Test New York William Jack
Jack Jacking Paris Noah Saad
Adam King Rabat William Sara
Sara Best Madrid Benjamin Adam
Briefly: I want to get the father's name by using only the name column. Is there a way to do that? (The order of the fathers’ names is incorrect, so I want to search using the name, if it is present in the father’s name, then it is the result I want)
Example: Saad test his father's name is Noah Saad (Match by Saad)
PS: I tried using LOOKUP, VLOOKUP and MATCH, but unfortunately the result is always N/A
PS 2: The data I have in Arabic is the reason why the above functions are not working?

I would use index() with match(), assuming your data starts in cell A1, like so:
=index(C1:C4,match(F1,A1:A4,0))
F1 contains the name that you look for.
Note, the classic problem is that there are extra spaces (leading or trailing) that make the names not identical.
You can trap errors as so:
=iferror(index(C1:C4,match(F1,A1:A4,0)),"Check")

You could do:
=INDEX( $C$2:$C$5, MATCH( "*" & MID( A2, 1, FIND( " ", A2 )-1), $C$2:$C$5,0) )
SolarMike - I think you have said the same, so I'm sorry if I am
stepping on your answer.

Related

Case sensitive problem in Excel’s pivot table

Example below, the ID of people are case sensitive (if don’t consider the case, some of them are of the same, for example, David’s and Mike’s, Lilly’s and John’s).
When putting them into a pivot table, it displays the same IDs for different people, i.e. David’s = Mike’s, Lilly’s = John’s.
Is there a way to have the pivot table to display actual IDs (case sensitive)?
ID Name
Txze David
TxZe Mike
TwgQ Lucy
3RqM Lilly
3RQm John
TvrE Kate
So, had a quick go with index() and match() as suggested in my comment:
INDEX(A$2:A$7,MATCH(D2,$B$2:$B$7,0))
D2 and D4 contain the Name looked for and the results are in F2 & F4, which give the different results. Note, 0 is used for an exact match in the match function.

Find the position of a related string in a list

In my worksheet, B2:F2 and B8:D8 are already filled in.
I would like to find the formulas for B9:D9. For instance, B9 is 2 because we can find Lee in Lee XXXX and Lee is at the second place of B2:F2. C9 is 4 because we can find Jim in Jim XXXX and Jim is at the second place of B2:F2.
To check the relation of Lee and Lee XXXX (Jim and Jim XXXX), we could use SEARCH, left_substring (if such a function exists).
Both single formulas or array formula will be fine. Using LAMBDA function is secondary choice, because it is still in preview.
Could anyone help?
If what is needed is always the first "word":
=MATCH(LEFT(B8,FIND(" ",B8)-1),$B$2:$F$2,0)
If you want to search on any position in the string:
=AGGREGATE(15,7,(COLUMN($B$2:$F$2)-MIN(COLUMN($B$2:$F$2))+1)/(ISNUMBER(SEARCH(" "&$B$2:$F$2&" "," "&B8&" "))),1)
With FILTER instead of AGGREGATE:
=#FILTER((COLUMN($B$2:$F$2)-MIN(COLUMN($B$2:$F$2))+1),ISNUMBER(SEARCH(" "&$B$2:$F$2&" "," "&B8&" ")),"")

Finding the index of a matching wildcard in excel

Given a sheet like so:
Sheet 1
Product Name
-----------------
Fancy Shoes
Plain Shoes
Comfy Slippers
Nice Loafers
Pressed Shirt
Tee Shirt
Collared Button-Up
and a sheet of wildcards:
Sheet 2
Product Wildcard | Product Category
---------------------------------------
*Shirt | Shirt
*Button-Up | Shirt
*Shoes | Shoes
*Loafers | Shoes
*Slippers | Shoes
I'm hoping to produce the following:
Product Name | Product Category
----------------------------------------
Fancy Shoes | Shoes
Plain Shoes | Shoes
Comfy Slippers | Shoes
Nice Loafers | Shoes
Pressed Shirt | Shirt
Tee Shirt | Shirt
Collared Button-Up | Shirt
In other words, can I lookup a category for a product in Sheet 1 that matches a Product Wildcard in Sheet 2?
I've tried to use VLOOKUP('Sheet 1'!A2, 'Sheet 2'!A2:B6, 2, FALSE) and MATCH('Sheet 1'!A2, 'Sheet 2'!A2:A6, 0). Both give me #N/A. I suspect those functions expect the search text to be the only thing that can be wildcarded and my Product Wildcards are taken literally and not interpreted as wildcards.
I'm wondering if there is another way to do this with built-in Excel functions, or if I'm going to need to write some VBA?
Thanks in advance for help on this!
The below is an array formula (entered with Ctrl+Shift+Enter):
=INDEX(Sheet2!$B$1:$B$5,MATCH(1,MATCH(Sheet2!$A$1:$A$5,Sheet1!A1,0),0))
You can use "Formulas" > "Evaluate Formula" on the cell containing the formula to see how it's working step by step.
Based on my reading here (specifically the note at the bottom), this seems to not be possible using VLOOKUP alone. If all of your wildcards don't have spaces, you could do it like this: (not an explicit formula, just a list of algorithmic steps)
Reverse the string, with something like this (this is an array formula, so Ctrl+Shift+Enter is required to use it)
Use FIND to get the location of the first space in the reversed version, subtracting that from the LEN of the string gives you the amount of string before the wildcard bit.
Use RIGHT to truncate the string to the wildcard, and use that with VLOOKUP.
If there are only two words in each cell and the word that determines the category (ex.: Shoes, Slippers, Shirt, etc...) is always second, you can use the following INDEX/MATCH to get the category:
=INDEX('Sheet 2'!B$2:B$6,MATCH(MID('Sheet 1'!A2,FIND(" ",'Sheet 1'!A2)+1,LEN('Sheet 1'!A2)-FIND(" ",'Sheet 1'!A2)),'Sheet 2'!A$2:A$6,0))

Task complete excel function

I have a 2 tables one is the DB and other is the UI; My EmployeeDB table is something like this:
Name: Task 1 Task 2 Task 3
John Smith X X X
Alexandra Kole X X
Jane Austin X
And in my UI table I have employee names in the first column, and I want to show the status of whether all the tasks are completed or not. So it has to be something like this.
Name: Status
John Smith Complete
Alexandra Kole Incomplete
Jane Austin Incomplete
I have this formula that I have pasted to the Status column of this table:
=IF(EmployeeDB[Name]=B4;IF(OR(EmployeeDB[Task 1]=""; EmployeeDB[Task 2]=""; EmployeeDB[Task 3]=""); "Incomplete"; "Complete"); "n.a").
But it only works for the first employee in the status table, for the others, the result is n.a, even though the employee is on the DB.
Could you please state what is the problem, and how it can be fixed?
Try,
=IF(COUNTA(INDEX(DB[[Task 1]:[Task 3]], MATCH([#[Name:]], DB[Name:], 0), 0))=3, "Complete", "Incomplete")
You already have a nice solution given which avoids volatile Indirect. Here is with indirect
H2 drag down
=IF(NOT(COUNTBLANK(OFFSET(INDIRECT(CELL("ADDRESS",INDEX(A2,MATCH($G2,$A2:$A4,0)))),,1,1,3))),"COMPLETE","INCOMPLETE")
Data
This will work:
Under presumption your data starts at B2 and ends at let's say D2,
like so:
Then the following formula will work.
=IF(COUNTA(B2:D2) = COLUMNS(B2:D2), "Complete", "Incomplete")
This solution is however very simplified, if you want to match the names to specific index, you should use the solution #QHarr provided. This should only illustrate an easy workaround.

VLOOKUP MULTIPLE RANGES

Column A and B is a item and country post code. Column B contain two country post code USA and UK. Both country we have dispatched same part. I am trying to create vlookup formula corresponding to the range but its return na. Please help me.
Country code ranges;
USA Angeles10 Angeles20 Angeles30 Angeles40 Angeles50 Angeles60 Angeles70 Angeles80 Angeles90 Angeles100 Angeles110 Angeles120 Angeles130 Angeles140 Angeles150
UK London10 London20 London30 London40 London50 London60 London70 London80 London90 London100 London110 London120 London130 London140 London150
DATA
ITEM POST CODE
4 Angeles10
4 Angeles20
110489 Angeles30
110489 Angeles40
113388 Angeles50
113388 Angeles60
113636 Angeles70
113636 Angeles80
11363613001 Angeles90
11363613001 Angeles100
11363613002 Angeles110
11363613002 Angeles120
11363613003 Angeles130
11363613003 Angeles140
1136362001 Angeles150
4 London10
4 London20
110489 London30
110489 London40
113388 London50
113388 London60
113636 London70
113636 London80
11363613001 London90
11363613001 London100
11363613002 London110
11363613002 London120
11363613003 London130
11363613003 London140
1136362001 London150
DESIRED RESULT
ITEM USA UK
4 Los Angeles10 London10
I put the first data on a sheet named datasheet in starting in A1.
Then use a formula like so in the E3:
=INDEX($B:$B,AGGREGATE(15,6,ROW($B$2:$B$31)/((ISNUMBER(MATCH($B$2:$B$31,INDEX(datasheet!$1:$1048576,MATCH(E$2,datasheet!$A:$A,0),0),0)))*($A$2:$A$31=$D3)),1))
Then copy/drag over and down.
Easiset Answer
If your data isn't changing and you know exactly where Angeles stops and London starts, you can just use a standard VLOOKUP formula. You just give the bottom part of the table to the UK column.
E3: =VLOOKUP(D3,A$3:B$6,2,)
F3: =VLOOKUP(D3,A$7:B$10,2,)
A little more complicated
If you need to be able to add rows or locations, this solution will work better. Add helper columns for each of the locations you need and a helper column which combines the item ID with the location. You can then use VLOOKUP by searching for the combination of item ID and location.
B3: =A3&CONCAT(D3:E3) (can expand past E3 for extra locations)
D3: =IF(ISERR(SEARCH(D$2,$C3)),"",D$2)
E3: =IF(ISERR(SEARCH(E$2,$C3)),"",E$2) (can drag right for each extra location)
H3: =VLOOKUP($G3&H$2,$B$3:$C$10,2,)
I3: =VLOOKUP($G3&I$2,$B$3:$C$10,2,) (can drag right for each extra location)
My favorite Answer
Just use Scott Craner's approach! ☺

Resources