Find and extract string from a cell text

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
704
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
I need a formula that finds and extract "month of 2020" in columns A.
Example:
Column A
1 Test
2 Hi
3 1
4 2
5 3
6 This , of course, is the month of december of 2020, ok.
7 Any text.
8 6
9 3
The formula should:
1) Find the cell that starts with "This, of course"; (the patern can appear anywhere in column A) = Row 6
2) Extract text from cell "A6" between the last "of" and the last ",", in this case = "december of 2020".
Is there a way to do that? Thanks.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
I think point 2 is not correct
there should be middle "of" not last if you want "december of 2020"

6 This , of course, is the month of december of 2020, ok.
 
Upvote 0
Yes, sorry:

2) Extract text from cell "A6" between the second backwards "of" and the last ",", in this case = "december of 2020".
 
Upvote 0
try
rawrawCustom
TestTest
HiHi
11
22
33
This, of course, is the month of december of 2020, ok.This, of course, is the month of december of 2020, ok.december of 2020
Any text.Any text.
66
33

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"raw", type text}}),
    IF = Table.AddColumn(Type, "Custom", each if Text.Contains([raw], "This, of course") then Text.BetweenDelimiters([raw], "of", ",", 1, 0) else null),
    Trim = Table.TransformColumns(IF,{{"Custom", Text.Trim, type text}})
in
    Trim

btw.
1) Find the cell that starts with "This, of course"; (the patern can appear anywhere in column A) = Row 6
6 This , of course, is the month of december of 2020, ok.
in the second bolded text you have space before comma so this is improper criteria
 
Upvote 0
Thanks! But I need to use a formula instead of Power Query.
 
Upvote 0
sure, this is one of several possible solutions :biggrin:
maybe someone else will give you formula solution
 
Upvote 0
How about
+Fluff v2.xlsm
ABC
11 Test
22 Hidecember of 2020
33 1
44 2
55 3
66 This , of course, is the month of december of 2020, ok.
77 Any text.
88 6
99 3
10
Master
Cell Formulas
RangeFormula
C2C2=TRIM(LEFT(SUBSTITUTE(MID(INDEX(A1:A10,MATCH("*Of course*",A1:A10,0)),SEARCH("month",INDEX(A1:A10,MATCH("*Of course*",A1:A10,0)))+9,100),",",REPT(" ",100)),100))
 
Upvote 0
Hi Fluff,
I was unable to to adapt this to my actual worksheet.
This formula works with more than 10 rows and with any phrase that starts with "This..." and at the end there's "...of december of 2020...."?
Thanks!
 
Upvote 0
Can you help me, if that is possible, to write a formula that returns the row which starts with a given text?
I tried: =MATCH("This*",A:A,0) but this does not works.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,255
Members
448,556
Latest member
peterhess2002

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