extract month from Txt

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,115
Office Version
  1. 2021
Platform
  1. Windows
I have text data in col A


I need to extract the month in Col B


I have tried to set up a formula to do this but where the number of characters changes for a particular month, it does not work


It would be appreciated if someone could assist me




Book1
AB
1DescriptionMonth
2Sales Data for February 2019February
3Sales Data for March 2019March 20
4
Sheet1
Cell Formulas
RangeFormula
B2=MID(A2,FIND("for",A2)+4,8)
B3=MID(A3,FIND("for",A3)+4,8)
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,434
Office Version
  1. 365
Platform
  1. Windows
If all dates are in 2019, you could use
=SUBSTITUTE(MID(A2,FIND("for",A2)+4,100)," 2019","")
 

AlanY

Well-known Member
Joined
Oct 30, 2014
Messages
4,342
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
try


Book1
ABCD
1DescriptionMonthMonth
2Sales Data for February 2019FebruaryJanuary
3Sales Data for March 2019MarchFebruary
4March
5April
6May
7June
8July
9August
10September
11October
12November
13December
125
Cell Formulas
RangeFormula
B2=LOOKUP(9.99E+307,SEARCH($D$2:$D$13,A2),$D$2:$D$13)
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,434
Office Version
  1. 365
Platform
  1. Windows
Alternately
=TRIM(LEFT(SUBSTITUTE(MID(A2,FIND("for",A2)+4,100)," ",REPT(" ",100)),100))
 

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,702
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

If it always prefixed with "Sales data for" and nothing else then here is another option.


Excel 2013/2016
AB
1DescriptionMonth
2Sales Data for February 2019February
3Sales Data for March 2019March
Sheet1
Cell Formulas
RangeFormula
B2=TEXT(REPLACE(A2,1,15,1),"mmmm")
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,115
Office Version
  1. 2021
Platform
  1. Windows
Thanks for the help FormR
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,115
Office Version
  1. 2021
Platform
  1. Windows

ADVERTISEMENT

Thanks for the help Alan
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,115
Office Version
  1. 2021
Platform
  1. Windows
Thanks for the help Fluff

Please explain how your formula works
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
73,434
Office Version
  1. 365
Platform
  1. Windows
Which one?
I would recommend using the formula from FormR, it's a lot neater :)
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,115
Office Version
  1. 2021
Platform
  1. Windows
Agree, it easier to follow


Please explain this part of your formula


Code:
," ",REPT(" ",100)),100))
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,602
Messages
5,838,321
Members
430,538
Latest member
PedroOliveira

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