strip based on a range.

topi1

Board Regular
Joined
Aug 6, 2014
Messages
161
Office Version
  1. 2010
Book1
ABCDE
1Toyota Highlander is popularToyotaHighlander is poularMazda
2General Knowledge GeneralKnowledgeHonda
3Mercedes BenzMercedes BenzToyota
4Ford
5General Motors
Sheet3


Hi, In the above example, I have data in the Columns A and E. Is it possible to have formula in B1 and C1 to see if the first word in A1 matches with any word in the column E, and if it does, put that word in B1 and the rest of A1 string in C1. If there is no match in the column E, then B1=A1 and C1 is blank. As in the example.
Thank you in advance.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Does this do what you want?

23 12 31.xlsm
ABCDE
1Toyota Highlander is popularToyotaHighlander is popularMazda
2General Knowledge GeneralKnowledgeHonda
3Mercedes BenzMercedes Benz Toyota
4Ford
5General Motors
First Word
Cell Formulas
RangeFormula
B1:B3B1=IF(ISNUMBER(MATCH("*"&LEFT(A1,FIND(" ",A1)-1)&"*",E:E,0)),LEFT(A1,FIND(" ",A1)-1),A1)
C1:C3C1=TRIM(SUBSTITUTE(A1,B1,""))
 
Upvote 0
Does this do what you want?

23 12 31.xlsm
ABCDE
1Toyota Highlander is popularToyotaHighlander is popularMazda
2General Knowledge GeneralKnowledgeHonda
3Mercedes BenzMercedes Benz Toyota
4Ford
5General Motors
First Word
Cell Formulas
RangeFormula
B1:B3B1=IF(ISNUMBER(MATCH("*"&LEFT(A1,FIND(" ",A1)-1)&"*",E:E,0)),LEFT(A1,FIND(" ",A1)-1),A1)
C1:C3C1=TRIM(SUBSTITUTE(A1,B1,""))
Fantastic. Perfect. I should have thought of C1. Not that it would have helped without B1. Thank you so much.
 
Last edited by a moderator:
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0
How about this variation...
In the following example, there are texts in the column A and range of texts in the column E. I would like a vba or formula in the column B which displays part of the string in the column A which has a match with one of the cells in the column E. Variable number of rows. for both columns A and E. The matching string can be in the start, end or anywhere in between in the sentence. Been trying since yesterday but can't find any solution. Found a way to see if there is a match or not but can't find a way to extract matching text.
Thank you in advance.

Book1
ABCDE
1VariablesFormulaRange
2Today is ThursdayThursadySUNDAY
3Tomorrow is FridayMONDAY
4Yesterday was Wednesday, a hump dayWednesday, a hump dayTUESDAY
5WEDNESDAY, A HUMP DAY
6THURSDAY
7
Sheet1
 
Upvote 0
Would this suffice?

24 01 03.xlsm
ABCDE
1VariablesFormulaRange
2Today is ThursdayTHURSDAYSUNDAY
3Tomorrow is Friday MONDAY
4Yesterday was Wednesday, a hump dayWEDNESDAY, A HUMP DAYTUESDAY
5WEDNESDAY, A HUMP DAY
6THURSDAY
Extract Text
Cell Formulas
RangeFormula
B2:B4B2=IFNA(LOOKUP(9.99E+307,SEARCH(" "&$E$2:$E$6&" "," "&A2&" "),$E$2:$E$6),"")
 
Upvote 0
Would this suffice?

24 01 03.xlsm
ABCDE
1VariablesFormulaRange
2Today is ThursdayTHURSDAYSUNDAY
3Tomorrow is Friday MONDAY
4Yesterday was Wednesday, a hump dayWEDNESDAY, A HUMP DAYTUESDAY
5WEDNESDAY, A HUMP DAY
6THURSDAY
Extract Text
Cell Formulas
RangeFormula
B2:B4B2=IFNA(LOOKUP(9.99E+307,SEARCH(" "&$E$2:$E$6&" "," "&A2&" "),$E$2:$E$6),"")
Thank you for your prompt response. Can't find IFNA in excel 2010. Looks like I need to get 2021 or 365. Is there a solution for 2010? Thank you.
 
Upvote 0
Can't find IFNA in excel 2010. ... Is there a solution for 2010?
Sorry, forgot about that. Use IFERROR instead

24 01 03.xlsm
ABCDE
1VariablesFormulaRange
2Today is ThursdayTHURSDAYSUNDAY
3Tomorrow is Friday MONDAY
4Yesterday was Wednesday, a hump dayWEDNESDAY, A HUMP DAYTUESDAY
5WEDNESDAY, A HUMP DAY
6THURSDAY
Extract Text
Cell Formulas
RangeFormula
B2:B4B2=IFERROR(LOOKUP(9.99E+307,SEARCH(" "&$E$2:$E$6&" "," "&A2&" "),$E$2:$E$6),"")
 
Upvote 0
Sorry, forgot about that. Use IFERROR instead

24 01 03.xlsm
ABCDE
1VariablesFormulaRange
2Today is ThursdayTHURSDAYSUNDAY
3Tomorrow is Friday MONDAY
4Yesterday was Wednesday, a hump dayWEDNESDAY, A HUMP DAYTUESDAY
5WEDNESDAY, A HUMP DAY
6THURSDAY
Extract Text
Cell Formulas
RangeFormula
B2:B4B2=IFERROR(LOOKUP(9.99E+307,SEARCH(" "&$E$2:$E$6&" "," "&A2&" "),$E$2:$E$6),"")
Brilliant. Thank you. I modified it for gaps in the column A with intermittent blank cells. Otherwise it was giving me "0" value in B column. Thanks.
 
Upvote 0
I modified it for gaps in the column A with intermittent blank cells. Otherwise it was giving me "0" value in B column.
Intermittent gaps in column A shouldn't cause a zero unless you also have intermittent gaps in the column E data. Anyway, glad you got it sorted. This would be my small change to deal with that.

24 01 03.xlsm
ABCDE
1VariablesFormulaRange
2Today is ThursdayTHURSDAYSUNDAY
3Tomorrow is Friday MONDAY
4  TUESDAY
5Yesterday was Wednesday, a hump dayWEDNESDAY, A HUMP DAYWEDNESDAY, A HUMP DAY
6
7THURSDAY
Extract Text
Cell Formulas
RangeFormula
B2:B5B2=IFERROR(LOOKUP(9.99E+307,SEARCH(" "&$E$2:$E$7&" "," "&A2&" "),$E$2:$E$7)&"","")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,327
Messages
6,124,289
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top