Logic function to combine all matching text into one cell - excel

I am looking for help with a formula that looks for all matching text and combines the results into a single cell. For example if the Country is Colombia I want a single cell to list all of the names that match Colombia.
ColA ColB
A1: COUNTRY NAME
A2: Argentina John Doe
A3: Bahamas Jan Doe
A4: Colombia James Doe
A5: Colombia Jason Doe
A6: Colombia Julian Doe
I've toyed around with CONCANTENATE and MATCH however they don't seem to be getting me what I need.

Related

How to search through an array of rows for a partial string in excel

I am used to Excel but am still pretty new to more complex formulas. I am trying to fill in the id field in the data table automatically based on the name.
I have two tables, one is a list of employees, and another is a log of associates' actions.
Here is the ID list.
A5 ID
A6 Name
123
Foo Bar
321
John Doe
246
Jane Doe
135
Mike Jones
Here is the log list.
A1 ID
A2 Name
A3 Action
Jane Doe
xxxxx
John Doe
abcdefg
Jane Doe
zzzzz
Foo Bar
yyyyyyy
I want to be able to take the current cell's index in the log and compare the name to the list of employees and copy the cell to the left of it to get the id.
Do you know of any formulas that would guide me to my goal?

Count repetitive values in column B based on unique value in column A

I have the following table:
1 John Doe
John Doe
2 Adam Smith
Adam Smith
Adam Smith
I need to count the number of times a name appears for each number value in column A. The numbers are unique.
Place this formula in cell C1 and drag down until the end.
=IF(ISNUMBER(A1),COUNTIF(B:B,B1),"")
n.b. - you can more clearly define row numbers instead of using B:B if you like as well

Counting the number of recurring substrings in a range of cells with a cell formula

I’m attempting to tally the occurrences of substrings that appear within a range of cells in a Google Sheet column, but I have a small complication which is preventing quick and easy solutions from calculating the correct totals. I put together a relatively simple example table below (sorry for the formatting) to demonstrate:
Column A: Names | Column B: Occurrences | Column C: List
A2: Adam | B2: [Blank] | C2: Charles; Adam
A3: Bob | B3: [Blank] | C3: Adam
A4: Charles | B4: [Blank] | C4: Smith, Charles
A5: Smith, Charles | B5: [Blank] | C5: Bob Evans
A6: Bob Evans | B6: [Blank] | C6: Smith, Charles; Charles; Bob
A7: [Blank] | B7: [Blank] | C7: Bob Evans; Charles; Bob
A8: [Blank] | B8: [Blank] | C8: [etc.]
The names that I’m searching for are in Column A. Column C has the actual list, where each name that appears (as found in Column A) is offset from other substrings with semicolons. For reference, Column C is--in my original worksheet--several hundred rows deep and will continue to grow as more data is added.
Now, I’ve used
=COUNTIF(C$2:C$7," * "&A2&" * ")
in B2 and so on to count the number of cells in which a name occurs, but it doesn’t get the totals right when one string from a cell in Column A appears as a substring elsewhere in Column A.
Column A: Names | Column B: Occurrences | Column C: List
A2: Adam | B2: 2 | C2: Charles; Adam
A3: Bob | B3: 3 [incorrect] | C3: Adam
A4: Charles | B4: 4 [incorrect] | C4: Smith, Charles
A5: Smith, Charles | B5: 2 | C5: Bob Evans
A6: Bob Evans | B6: 2 | C6: Smith, Charles; Charles; Bob
A7: [Blank] | B7: 2 | C7: Bob Evans; Charles; Bob
For example, although the exact string I need from A3 (“Bob”) appears only twice in the Column C list, the "COUNTIF" formula in B3 also includes C5’s “Bob Evans” (but does not count the “Bob” at the end of C7’s contents, because that cell has likewise already been counted for its “Bob Evans”). In the same vein, the count for “Charles” includes all cells which might only have “Smith, Charles” when it should only find “Charles.”
I imagine that a solution could involve "SPLIT" or "REGEXEXTRACT" to count only the substrings as they appear precisely in their Column A cells, but my attempts haven’t turned up the correct totals so far. Any guidance on how to get the right results with this setup (substrings separated by semicolons and using a cell formula to search the range of that column) would be welcome.
B3:
=ARRAYFORMULA(IF(A3="","",(SUMPRODUCT(REGEXMATCH(REGEXREPLACE($C$3:$C$15,"(\w+),{0,1}\s+(\w+)","$1$2"),".*(^|\s)"& trim(REGEXREPLACE($A3,"(\w+),{0,1}\s+(\w+)","$1$2"))&"(;|$).*")))))
We use REGEXREPLACE to find double names like Smith, Charles and combine them into a single entity ( Both in A3(Names Column) and C3:C7( List column)
Then we use REGEXMATCH to find whether the modified A3 matches in any of modified C3:C7
Then, We add them using SUMPRODUCT
NOTE: If you have given all the formats correctly (including number of spaces, , and ;, This will work perfectly. If you've messed up in your question, Then this will not work and you will have to figure out how to adapt this to your actual format.

VLOOKUP to check if a value exists in a cell

I have data like this in a column:
John L. Doe
Jane N. Doe
Michael A. Doe
I'm trying to match the entries against another column with this format.
doe, jane
doe, john
doe, michael
I've tried VLOOKUP's for the lastname and using wildcards:
VLOOKUP("*" & A1 & "*",B:B,2, FALSE)
but I'm getting #N/A as a result.
If your columns are labelled, then in C2 and copied down to suit:
=MATCH(TEXT(MID(B2,FIND(" ",B2)+1,LEN(B2))&"*"&LEFT(B2,FIND(",",B2)-1),"#"),A:A,0)
should return the row number of a match in ColumnA for the value in ColumnB that is in the same row as the formula result.
To match "the other way around" is very similar, and as it happens for the example the results the same:
=MATCH(TEXT(MID(A2,FIND(" ",A2,FIND(" ",A2)+1)+1,LEN(A2))&"*"&LEFT(A2,FIND(" ",A2)-1),"#"),B:B,0)

Excel: match value from an array and return cell value from the same row

I have some data in excel worksheet1 in this form:
person1 person2 person3 score
dave sarah jill 4
brandon hank 3
And in worksheet2 I have a column of people listed alphabetically, like this:
person score
alex
brandon
dave
hank
jill
sarah
I'd like to obtain each person's score from worksheet1 (with blanks for those who are absent):
person score
alex
brandon 3
dave 4
hank 3
jill 4
sarah 4
I've looked into functions like find, match, lookup, vlookup, but it seems like I will need something more complicated.
Assuming:
Each person can only ever occur once in the source data
The source data occupies the range A1:D3 (with headers in row 1)
The first person's name for which you wish to return a result is in G2
then this formula in H2:
=IF(COUNTIF($A$2:$C$3,G2),INDEX($D$2:$D$3,SUMPRODUCT(($A$2:$C$3=G2)*(ROW($A$2:$C$3)-MIN(ROW($A$2:$C$3))+1))),"")
Copy down to give equivalent results for names in H3, H4, etc.
Regards

Resources