I have an excel spreadsheet with items in column B beginning with the same text as column A, for example:
cell A1 - Groceries-Food-Fruit
cell B1 - Groceries-Food-Fruit - apples, oranges, pears
How can I remove the duplicate words, (Groceries-Food-Fruit) from cell B1 using a formula?
Thanks
I've researched ways of removing duplicates, but cannot find a formula for this particular situation
CodePudding user response:
If the format of the cells follow the same trend you posted then this would work:
=IFERROR(IF(ISNUMBER(SEARCH(A1:A10,B1:B10)),MID(B1:B10,LEN(A1:A10) IF(ISNUMBER(SEARCH(" - ",B1:B10))=TRUE,4,2),99),""),"")
If the entire value of cell A1 is found in the beginning of cell B2 then it trims it out. The benefit is it will work for several variations. Notice in B1 I removed the spaces around the hyphen and it still works.