Master Text Extraction with LEFT, RIGHT & MID (Split Hyphens, Spaces, and Codes in 1 Minute)

Master Text Extraction with LEFT, RIGHT & MID (Split Hyphens, Spaces, and Codes in 1 Minute)

Master Text Extraction with LEFT, RIGHT & MID (Split Hyphens, Spaces, and Codes in 1 Minute)

Product codes, file extensions, email domains… With LEFT/RIGHT/MID, you can accurately extract only the part you need. We’ll also cover the TEXTBEFORE/TEXTAFTER alternatives in the latest Microsoft 365.

Basic Syntax & Arguments

FunctionSyntaxDescription
LEFT=LEFT(text, [num_chars])Returns the specified number of characters from the left
RIGHT=RIGHT(text, [num_chars])Returns the specified number of characters from the right
MID=MID(text, start_num, num_chars)Returns a specified number of characters starting at a given position

TIP start_num begins at 1, not 0.

Fixed-Length Extraction (Prefixes/Suffixes)

Example 1) Product code prefix (first 3 characters)

=LEFT(A2,3)

Example 2) Last 4 digits of a serial number

=RIGHT(A2,4)

Example 3) 5 characters starting with the 4th character

=MID(A2,4,5)

Extract by Delimiter (Hyphens, Spaces, and Periods)

Example 4) Product category before a hyphen

=LEFT(A2, FIND("-",A2)-1)

Example 5) Detail code after a hyphen

=RIGHT(A2, LEN(A2)-FIND("-",A2))

Example 6) Last name after a space (for example, “Kim Minsoo” → “Minsoo”)

=RIGHT(A2, LEN(A2)-FIND(" ",A2))

Example 7) Email domain

=RIGHT(A2, LEN(A2)-FIND("@",A2))
  • FIND is case-sensitive, while SEARCH is not.
  • In Microsoft 365, TEXTBEFORE/AFTER is simpler: =TEXTAFTER(A2,"-")

Working with the Last Delimiter (File Extensions and Names)

Sometimes you need to work from the end, such as when extracting a file extension after the final period (.) or a word after the final space.

Example 8) File extension (after the last period)

=RIGHT(A2, LEN(A2) - FIND("|", SUBSTITUTE(A2, ".", "|", LEN(A2)-LEN(SUBSTITUTE(A2,".","")))))

Example 9) Word after the last space

=RIGHT(A2, LEN(A2) - FIND("|", SUBSTITUTE(A2, " ", "|", LEN(A2)-LEN(SUBSTITUTE(A2," ","")))))

For Microsoft 365 users, it’s even easier:

=TEXTAFTER(A2, ".", -1)    // file extension
=TEXTAFTER(A2, " ", -1) // last word

Variable-Length Codes & the Nth Word

Example 10) Extract text between hyphens (middle code)

=MID(A2, FIND("-",A2)+1, FIND("-",A2, FIND("-",A2)+1) - FIND("-",A2) - 1)

Example 11) Nth word (Microsoft 365)

=TEXTSPLIT(A2," ")(1,3)  // third word

Example 12) Nth word (traditional method)

=TRIM(MID(SUBSTITUTE(A2," ",REPT(" ",99)), (N-1)*99+1, 99))

Cleanup & Error Handling (TRIM/CLEAN/IFERROR)

=IFERROR( TRIM(SUBSTITUTE(MID(A2,4,5),CHAR(160)," ")), "" )
  • TRIM: Removes extra spaces
  • CLEAN: Removes nonprinting characters
  • SUBSTITUTE: Replaces nonbreaking spaces (CHAR(160)) with regular spaces
  • IFERROR: Handles exceptions such as a missing delimiter with a blank value or message

Common Mistakes and Solutions

  • Assuming indexes start at 0 → MID(text,1,1) returns the first character.
  • Mixed Korean and English text length → In general, LEN and MID are sufficient. Use LENB/LEFTB/MIDB/RIGHTB only when you need byte-based counts.
  • Repeated delimiters → Split with TEXTSPLIT, then use INDEX to select the part you need.
  • Codes that look like numbers → Store them as text to preserve leading zeros (use a leading apostrophe ‘ or apply the Text cell format).

Summary

GoalTypical Formula
Prefix/suffixLEFT(A2,n), RIGHT(A2,n)
Before/after a delimiterLEFT(A2,FIND("-",A2)-1), RIGHT(A2,LEN(A2)-FIND("-",A2))
After the last delimiterTEXTAFTER(A2,"-", -1) or a SUBSTITUTE-based formula
Middle text (between two delimiters)Two nested MID + FIND calls

FAQ

Should I use FIND or SEARCH?

FIND is case-sensitive, while SEARCH is not. They work almost identically with Korean text; choose FIND only when you need case sensitivity for English text.

I need to perform calculations on numbers after splitting text.

If you extracted only numbers from a text string, convert them with VALUE(), or calculate using numbers in the original data and format the output as text.

Choose a code, name, or email address in the report you are working on and apply LEFT · RIGHT · MID right away. A 1-minute investment can cut repetitive work time in half.

Leave a Reply

Your email address will not be published. Required fields are marked *