Find and extract string from a cell text

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
693
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.
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
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.
 

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
693
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Yes, sorry:

2) Extract text from cell "A6" between the second backwards "of" and the last ",", in this case = "december of 2020".
 

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
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
 

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
693
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows

ADVERTISEMENT

Thanks! But I need to use a formula instead of Power Query.
 

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
sure, this is one of several possible solutions :biggrin:
maybe someone else will give you formula solution
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,749
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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))
 

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
693
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,749
Office Version
  1. 365
Platform
  1. Windows
I was unable to to adapt this to my actual worksheet.
In that case please post some data this is representative of your actual data.
 

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
693
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,072
Messages
5,628,476
Members
416,320
Latest member
Insightful111

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
Top