Function Problems

How to Extract Month and Year Codes from Text in Excel

Bushra ParveenBushra Parveen Oct 16, 2026 870 views

Question details

The user needs to extract specific month and year combinations (like JAN 23) from within complex text strings in an Excel worksheet.

How to Extract Month and Year Codes from Text in Excel
Product
Excel
Device & OS
not provided
Scenario
Analyzing text data that contains embedded date abbreviations (three-letter month and two-digit year) within a predefined date range.
Observed behavior
The goal is to automatically search through text and isolate specific month-year codes without manually reading and retyping the dates.
Before you start

Determine the specific date range you need to extract (e.g., January 2022 to December 2023) and verify that the target text consistently follows the three-letter month and two-digit year format separated by a space (mmm yy).

Solution 1Recommended

Use the LET and FILTER Formulas to Extract Month-Year Codes

Create a dynamic array formula that generates a sequence of valid month-year combinations and searches the text string for them.

This method uses the LET function to build a virtual list of months, then searches the target cell for any matching date codes. It is highly effective for datasets where dates fall within a known timeframe.

1
Select the destination cell

Click on the cell where you want the extracted date code to appear, for example, cell B2.

2
Enter the extraction formula

Type the following formula: =LET(dtsq,TEXT(EDATE(DATE(2022,1,1),SEQUENCE(24,1,0,1)),"mmm yy"),ARRAYTOTEXT(FILTER(dtsq,ISNUMBER(SEARCH(dtsq,A2)))))

3
Apply the formula to the column

Press Enter to execute the formula. Then, click the small square at the bottom-right corner of the cell and drag it down to fill the formula across your entire dataset.

Use the LET and FILTER Formulas to Extract Month-Year Codes
Customizing the Date Range: In the formula, DATE(2022,1,1) sets the start date as January 2022. The SEQUENCE(24,1,0,1) segment tells Excel to generate 24 consecutive months. You can modify these numbers to adjust the start date and the total number of months you want to search for.
Extract Data Easily with WPS Office

Seamless Data Extraction and Analysis in WPS Spreadsheet

WPS Spreadsheet fully supports advanced dynamic array formulas like LET, FILTER, and SEQUENCE, allowing you to seamlessly extract dates and manipulate text data exactly as you would in Microsoft Excel.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open the Excel file containing your text data.
  2. 2. Enter the formula: Click the cell next to your source data and input the exact LET and SEQUENCE formula used for extraction.
  3. 3. Fill the data: Press Enter, then double-click the fill handle to apply the extraction formula to all rows in your dataset effortlessly.
Fully compatible with Microsoft Excel (.xlsx) formats and functionsNatively supports modern array formulas including LET and SEQUENCELightweight, fast, and free to use for everyday tasksIntuitive interface for seamless data manipulation
microsoft office alternative - wps office

Frequently Asked Questions

Why does the formula return an error if no date is found in the text?

If the text does not contain a valid month-year combination within your defined sequence, the FILTER function may return a #CALC! error because the filtered array is empty. You can wrap your entire formula in an IFERROR function to return a blank cell instead, like this: =IFERROR(LET(...), "").

Can I extract full month names and four-digit years instead?

Yes. You just need to change the date format code in the TEXT function portion of the formula from "mmm yy" to "mmmm yyyy". Ensure that the text strings you are searching also contain dates in this exact full format.

Does this formula distinguish between uppercase and lowercase letters?

No, the SEARCH function used in the formula is case-insensitive. It will successfully identify and extract 'JAN 23', 'Jan 23', or 'jan 23' without requiring any modifications to the formula.