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)
Related
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:
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.
sorry if this has already been asked, have read many answers about this, (this is the one that best describes my situation - Excel - Match cells that contains exact match from list )
I would like Excel to index a column where the cells contain comma separated lists of values. Some lists have only one entry and thus no comma.
I would like Excel to find an exact match for a given string, for example, if I search for "C2" I would like it only to find "C2" and not "C22" or "C230". It should also find "C2,"
I have got this to work for single cells with this formula :
=ISNUMBER(FIND(" "&E$1&", "; " "&$B1&", "))
Where "C2" is contained in cell E1 and the comma separated list is in cell B1.
However, if I try to incorporate this into an INDEX formula (I would like it to return the corresponding value from the cell in column A where C2 exists), it once again finds all instances of "C2". I wrote the formula as follows :
=INDEX(A:A;ISNUMBER(FIND(" "&E$1&", "; " "&B:B&", ")))
If anyone has any advice on how to get this to work, I would be most grateful!
Katrina
Use the =ISNUMBER(FIND(" "&E$1&", "; " "&$B1&", "))function in an auxiliary column, say F, and pull it down along the comma-separated values in B.
Use =INDEX(A:A;MATCH(TRUE;F:F;0)). This will find the first occurrence of C2 or #NV in cases where C2 does not occur.
Note that the function will find "C2" and "C2, " but not "C2,".
=SUMPRODUCT(ISNUMBER(FIND(" "&E$1&", "; " "&B:B&", "))*A:A)
SUMPRODUCT works great with arrays. The ISNUMBER function returns an array of false/0 and true/1 that is then multiplied with the respective value in column A, returning only that value in A where ISNUMBER is true. If there are several occurrences of the E1 value, the sum of the respective values in A is returned.
For better performance the ranges in A and B should be restricted to those where values are possible, say A1:A100 and B1:B100.
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"))))
There are two types of values in cell A of my spreadsheet
Value type 1: Have a space in between the postcode district and sub postcode, as the postcode district is less than ten (i.e. MK1-MK9)
MK1 1AS
Value type 2: Have no space in between, as the postcode district is greater than ten (i.e. MK10-MK46)
MK170DB
What would be the best way of splitting the second group of values into something like this:
MK17 0DB
I was thinking of some pseudo code in the the vein of:
if the value at the 4th character (counting from the right) in MK170DB is not an empty space
then count 4 spaces and create an empty character, leaving it like this MK17 0DB
if not then presume that the 4th character is a empty space (i.e. MK1 1AS) and leave it
As I just need to run this operation once to cleanse my data, I was thinking about creating a formula in column B that references column A and does the necessary cleansing. I would then replace the values in col A with what I have in col B.
Can anyone tell me whether the logic I have proposed can be executed in Excel or if there is a better way of doing it?
Thanks.
With your data in A1, in B1 enter:
=IF(ISERROR(FIND(" ",A1)),LEFT(A1,4) & " " & MID(A1,5,999),A1)
Something I came up with, which appears to work...
=IF(MID(A1,4, 1)=" ",A1,REPLACE(A1,5,0," "))