Using Index/Match on external sheet with delimited cells - excel

I have a spreadsheet, Alpha that references an external spreadsheet Bravo.
I need Alpha's B2 cell to check in Bravo for all cells in column A that contain the string in Alpha A2. If it finds a match it copies the value from the B column for that row to Alpha B2. I've currently got this working using the following formula:
=INDEX([Bravo.xlsb]Sheet1!A$2:B$22,MATCH(A2,[Bravo.xlsb]Sheet1!$A$2:$A$22,0),2)
..however, I have some cells in Bravo that have multiple strings separated by delimiter that need checking. To complicate matters some of the reference cells in Alpha's A column have multiple strings separated by delimiter. Ideally the images below show how I need this formula to work:
Alpha.csv:
Bravo.csv:
So my question is, how can I modify the formula to work with cells that contain delimitered strings as well?
Update
To clarify this is how Alpha looks before any formula is run:
Alpha.csv (pre-formula)
Items Category Group (results)
Oranges|Chicken
Ice Cream|Pears|Steaks
...and this is how Bravo looks
Bravo.csv
Item Categories Category Group
Fruits>Pears|Fruit>Oranges Fruits & Health
Meat>Steaks|Meat>Chicken|Meat>Lamb Meats
Deserts>Ice cream Deserts & Sweets
I need B2 of Alpha to take each string in A2 (separated sometimes by delimiter for multiple strings) check through Bravo A column for a match for each string. If it finds a match it adds the corresponding category Group name from Bravo's B column to the Alpha B2 cell.
It repeats this for each string in A2 and if there are multiple strings adds in a | delimiter until all strings have been checked. The result would look like this:
Alpha.csv (post-formula)
Items Category Group (results)
Oranges|Chicken Fruits & Health|Meats
Ice Cream|Pears|Steaks Deserts & Sweets|Fruits & Health|Meats

One option would be to simply use the Text-to-Columns feature to delimit your list in your Alpha document. That will allow you to use this formula:
=INDEX([Bravo.xlsx]Sheet1!$B:$B,MATCH("*"&A2&"*",[Bravo.xlsx]Sheet1!$A:$A,0))
This formula looks for the value in Alpha A2 with any values before it and any values after it within column A in Bravo.
Otherwise you would have to be more specific on what you which category you would like to search, in which case you can utilize right() mid() and left() to adjust your match() function.

Related

Splitting names given in single cells without using text to column excel

i want to use excel formula to split multiple names given in a single cell. dont want to use text to column feature. For example
in the above yellow is the variable name & the green color is the required format
See find the nth instance of a character: FIND(CHAR(1),SUBSTITUTE(string,delimiter,CHAR(1),nth)). For the first, we use LEFT(string,position_first-1). For the last: RIGHT(string,LEN(string)-position_last). For all in between: MID(string,position_first+1,position_second-position_first-1).
So, combining the logic, we may get this:
=IFERROR(IFERROR(IF(B$1=1,LEFT($A2,FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),1),1)-1),MID($A2,FIND(CHAR(160),SUBSTITUTE($A2,"/",CHAR(160),B$1-1),1)+1,FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),1+B$1-1),1)-FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),B$1-1),1)-1)),RIGHT($A2,LEN($A2)-FIND(CHAR(1),SUBSTITUTE($A2,"/",CHAR(1),B$1-1),1))),"")
IFERROR(...,"") is used to return "" after last occurrence (below, in G2). Nested IFERROR(... RIGHT) will be triggered at last occurrence (since MID will fail there; below at F2).
Try using this:
With the full name in cell A2, the formulas go as follows:
Get the first name:
=LEFT(A2,SEARCH(" ",A2)-1)
Get the last name:
=RIGHT(A2,LEN(A2)-SEARCH(" ",A2,1))
You enter the formulas in cells B2 and C2, respectively, and drag the fill handle to copy the formulas down the columns. The result will look something similar to this:

Find and remove unique values within a phrase across multiple cells

Have hit a complete roadblock on this one - I am trying to remove unique values within a Product Name column by comparing multiple cells. The end result is to create a logical 'category' in column B for each row, something like this:
Category Result Example:
Where I am coming unstuck is because there may be duplicates at various points in the string that clash e.g "Shirt Blue" in A2 & "Shirt Blue" in A4.
What might save me is the first 2 words, or roughly 10 characters, of 'like' products are always identical across cells so in essence I am trying to find a formula that will check if the first 10 characters are identical and then remove any remaining unique values from all cells in the range
This will not really do everything you need, but if you just want to pick up the first 2 words, you can find everything before the second space using this formula:
=LEFT(A1,FIND(" ", A1,FIND(" ", A1)+1)-1)
To increase the number of words to look for, you just need to add more FINDs in, like so:
=LEFT(A1,FIND(" ", A1, FIND(" ", A1,FIND(" ", A1)+1)+1)-1)

excel: if cell contains multiple criteria then return multiple criteria, nestled?

I have 4 criteria lists that look like this:
A B
Name Category
Name Category
Name Category
And a MasterList like this:
A B
stuffNAME Category
NAMEstuff Category
NAME Category
I would like to know if there is a formula that can search through each criteria list based on the MasterlistA column for "NAME" and return the appropriate "Category" in MasterlistB.
As an example:
I'm looking to return MasterlistB based on MasterlistA
Criteria List:
A B
NBC NBCU
Disney ABC
Masterlist:
A B
NYC NBC 20998 NBCU
NJ2987 NBC NBCU
Disney Florida99 ABC
I'm simplifying, but in reality the criteria lists all refer to different masterlist columns as well. Trying to get the matching/searching part down first.
Given a setup as shown in #ScottCraner 's answer:
In cell E1 and copied down:
=IFERROR(LOOKUP(1,1/COUNTIF(D1,"*"&$A$1:$A$2&"*"),$B$1:$B$2),"No Match")
This is a regular formula and does not require array entry.
You can do this using VLOOKUP, nested with the IFERROR statement.
I am assuming each table is starting on A1, in sheets called Sheet1, Sheet2, Sheet3, and Sheet4. You may need to adjust references to point to appropriate tables.
The basic formula to find the category which matches your name, is simply [assuming your search term is on a new sheet on A1, let's say Sheet5, with the rest of your final data table]:
=VLOOKUP(A1,'Sheet1'!A:B,2,0)
This simply takes the value in A1 [the search term], tries to find it in column A of sheet 1, and if it does find it, takes the first matching row, and returns the value on the 2nd column in [column B, with the category].
If that fails, you simply put that inside of IFERROR, which attempts to calculate something, and if it creates an error, returns something else, like so:
=IFERROR(VLOOKUP(A1,'Sheet1'!A:B,2,0),"NO MATCH FOUND")
Now to use the IFERRORS to first attempt to find a match on Sheet1, then Sheet2, etc., put the following:
=IFERROR(VLOOKUP(A1,'Sheet1'!A:B,2,0),IFERROR(VLOOKUP(A1,'Sheet2'!A:B,2,0),IFERROR(VLOOKUP(A1,'Sheet3'!A:B,2,0),VLOOKUP(A1,'Sheet4'!A:B,2,0))))
To search for only a partial match, you can use the following:
=VLOOKUP("*"&A1&"*",'Sheet1'!A:B,2,0)
The "*" act like wildcards, and if they are included in front of and behind your search term [in this case, A1], then anything that contains your search term, regardless of its position in a cell, will be considered a match. You can replace A1 in all of my above formulas with this revised wildcard match to check for partial matches in any of your sheets.
To search a list of items, which exactly match a part of your search term
You could probably do this with an array formula, but because you have multiple data tables, I think the easiest solution is to use a helper column next to each of those tables, to create a unique ID which actually matches to your Master List. ie:
On Sheet1 [and all other category sheets], insert a new column in between A & B; this column will trace back from column A, to match a Name from your Master List on Sheet5, like so [starting in B1 & copied down]:
=VLOOKUP("*"&A1&"*", 'Sheet5'!A:A, 1, 0)
Your revised formula in your master sheet would now look like this:
=IFERROR(VLOOKUP(A1,'Sheet1'!B:C,2,0),IFERROR(VLOOKUP(A1,'Sheet2'!B:C,2,0),IFERROR(VLOOKUP(A1,'Sheet3'!B:C,2,0),VLOOKUP(A1,'Sheet4'!B:C,2,0))))
Rather than placing the four lists side-by-side like:
Stack them on top of each other like:
The its as simple as:
=VLOOKUP("David",A1:B12,2)
So here is the basic formula to get what you want:
=INDEX($B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & $A$1:$A$2 & "*",D1))),1))
if you have 2010 or later. If you have 2007 and earlier than you will need to use the following array formula:
=INDEX($B$1:$B$2,SMALL(IF(ISNUMBER(SEARCH("*" & $A$1:$A$2 & "*",D1)),ROW($1:$2)),1))
It being an array formula it must be confirmed with Ctrl-Shift-Enter.
In the picture, the first formula is Column F, the second in Column E
You will need to add nested IFERROR() Functions for the various sheets.
=IFERROR(INDEX(Sheet1!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet1!$A$1:$A$2 & "*",A1))),1)),IFERROR(INDEX(Sheet2!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet2!$A$1:$A$2 & "*",A1))),1)),IFERROR(INDEX(Sheet3!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet3!$A$1:$A$2 & "*",A1))),1)),IFERROR(INDEX(Sheet4!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet4!$A$1:$A$2 & "*",A1))),1)),"NOT HERE"))))

Excel Formula - If contains text, result text

I've got a weird Excel problem that is giving me a mind block. Basically, this is what I've got:
Column A contains strings of text, which all contain company names and a bunch of other info. I'd like to strip out those names. I've got a list of the names I'm searching for.
**Contractor**
CompanyA
CompanyB
CompanyC
CompanyD
And strings like this:
CompanyA REQ# G-FMR-036 PT 2
CompanyA Pad AN Structural Steel ()
COMPANYC REQ# 54
CompanyA REQ# G-FMR-049
What I would like is the formula to return whichever of the company names appears in that string. My first thought was a giant nested formula of IFs and SEARCHes but I know there has to be a better way.
With the list to search in A1:A4 and the list of company names in B1:B4, this array formula, entered with CtrlShiftEnter will do it:
=INDEX($B$1:$B$4,MATCH(TRUE,ISNUMBER(SEARCH($B$1:$B$4,A1)),0))
A bit of a kludge but better than nested IFs:
I am explaining for the example you gave above (4 companies); you should be able to figure out how to extend this.
In column A have your strings that include company names and the extra stuff. Let's assume A1 has some column title, and your 4 strings are in A2, A3, A4, A5.
In cells C1, D1, E1, F1 have the "clean" four company names.
In C2 have this formula:
=IF(ISERROR(FIND(UPPER(C$1), UPPER($A2))),"",C$1)
Then copy cell C2 to all the cells in C2:F5 . The formula will update automatically to fit each cell.
Then, in cell H2 have this formula:
=C2&D2&E2&F2
and then copy/paste it to H3, H4, H5.
In column H you will get what you are looking for.
Of course this assumes you have only one matching company name in each cell in column A, and that the names are exactly (up to case-sensitivity) the same as the company names in cells C1:F1 .
I take it that some of the company names contain spaces, otherwise you could just use:
=left(a1,find(" ",a1)-1)
If you need to compare the contents of the string against a list of companies, then with the list in a named range "CompanyList"; one entry per row; you could try something like:
=IFERROR(LOOKUP(2,1/ISNUMBER(SEARCH(CompanyList&"*",A1)),CompanyList),"Not in List")
However, if some names are similar, you will need to pay attention to the order in the list, as the formula will return the last entry that matches. So you want to put the longest string in Company List last.
This is what I've created so far, although I imagine there has to be a better way than nested formulas like whoa. I mean, it works, but it makes me want to cry.
=IF(ISNUMBER(SEARCH(T$3,B3)),"CompanyA",IF(ISNUMBER(SEARCH(T$4,B3)),"CompanyB",IF(ISNUMBER(SEARCH(T$5,B3)),"CompanyC",IF(ISNUMBER(SEARCH(T$6,B3)),"CompanyD","Other"))))

How to concatenate in cell

I want to concatenate two or more cell but i don't want to concatenate whole cell .Only want to take 2 or more character of 1st cell and 2 or more character of 2nd cell then concatenate them in the 3rd cell.Like..
Student Name Serial number Address Group Section Student ID
Monir 07001 Dhaka,Bangladesh Science B SC001B
I want to take last three digit from the Serial number cell, if it is science from the group cell i want to take only sc and if it is arts i want to take at from the group cell and from the section cell i want to take full character ,Finally concatenate into the Student ID cell.
How do i can do it. Please help me.
Build up what you need slowly:
The last three digits of Serial#: =RIGHT(B2, 3)
Create another table that maps: Science to Sc, Art to At and then use the LOOKUP function. eg =LOOKUP(D2, X2:X6, Y2:Y6), Where column X is filled with "Science, Art, etc" and Y is filled with "Sc,At, etc"
Concatenate is =CONCATENATE()
So the final answer would look something like:
=CONCATENATE(LOOKUP(D2, X2:X6, Y2:Y6), RIGHT(B2,3), E2)
Use LEFT(), RIGHT() or MID() functions for extracting substrings. Use the "&" operator to concatenate. For example:
=RIGHT(C1,3) & LEFT(D1,2) & E1
Excel. Programming. Hmmm.
Anyhoo, I suppose you could use the following:
=LEFT(E2,2) & RIGHT(B2,3) & D2
That gets the first two characters of E2, last three characters from B2 and D2.

Resources