Day 9: Manipulating Text – LEFT, RIGHT, and MID

Day 9: Manipulating Text – LEFT, RIGHT, and MID

Welcome to Day 9 of your Excel journey! So far, we’ve explored formulas for calculations and conditional counting. Today, we’ll focus on text manipulation using three powerful functions: LEFT, RIGHT, and MID. These functions allow you to extract and manipulate text from cells, making them invaluable for cleaning and reformatting data.

Let’s dive into these text functions and see how they can simplify your work.


Why Text Functions Are Useful

Text functions help you handle messy datasets, such as splitting names, extracting specific characters, or cleaning imported data.

  • Data Cleanup: Remove unwanted prefixes or extract essential parts of a string.
  • Reformatting: Break long text into smaller pieces for readability.
  • Data Analysis: Extract key information, such as codes, initials, or product identifiers.

Key Functions: LEFT, RIGHT, and MID

1. LEFT: Extracting Text from the Beginning

The LEFT function extracts a specific number of characters from the beginning of a string.

Syntax:
=LEFT(text, num_chars)

  • text: The cell containing the text.
  • num_chars: The number of characters to extract.

Example:
If cell A1 contains “Apple123”, the formula =LEFT(A1, 5) returns “Apple”.


2. RIGHT: Extracting Text from the End

The RIGHT function extracts a specific number of characters from the end of a string.

Syntax:
=RIGHT(text, num_chars)

Example:
If cell A1 contains “Apple123”, the formula =RIGHT(A1, 3) returns “123”.


3. MID: Extracting Text from the Middle

The MID function extracts characters starting from the middle of a string, based on a starting position and length.

Syntax:
=MID(text, start_num, num_chars)

  • text: The cell containing the text.
  • start_num: The starting position (the first character is position 1).
  • num_chars: The number of characters to extract.

Example:
If cell A1 contains “Apple123”, the formula =MID(A1, 6, 3) returns “123”.


Practical Example

Let’s use the following dataset to practice:

Product Code
AB123456
CD987654
EF135791

Exercise 1: Extract the Prefix

Extract the first two letters (prefix) from each product code:

  • Use the formula =LEFT(A2, 2).
  • Result for AB123456: “AB”.

Exercise 2: Extract the Suffix

Extract the last three numbers (suffix) from each product code:

  • Use the formula =RIGHT(A2, 3).
  • Result for AB123456: “456”.

Exercise 3: Extract the Middle Numbers

Extract the six-digit number from the middle of each product code:

  • Use the formula =MID(A2, 3, 6).
  • Result for AB123456: “123456”.

Advanced Tips for Text Functions

  • Combine with Other Functions: Use LEFT, RIGHT, or MID with functions like TRIM (to remove extra spaces) or VALUE (to convert text to numbers).
    • Example: =VALUE(RIGHT(A2, 3)) converts the suffix to a numeric value.
  • Dynamic Lengths: Combine text functions with LEN (to determine string length).
    • Example: =MID(A2, 3, LEN(A2)-5) extracts all but the first two and last three characters.

Common Mistakes to Avoid

  • Incorrect Start Numbers in MID: Remember that the first character starts at position 1.
  • Exceeding String Length: If you specify more characters than exist in the text, Excel will return the full string without errors.
  • Forgetting to Handle Empty Cells: Text functions applied to empty cells return "" (a blank result).

What’s Next?

You’ve now mastered how to extract and manipulate text in Excel! Tomorrow, on Day 10, we’ll dive into date and time functions like TODAY, NOW, and DATEDIF, which help you calculate time differences and handle dates dynamically.


SEO Keywords:

  • How to use LEFT in Excel
  • Extract text with MID in Excel
  • Excel RIGHT formula examples
  • Manipulate text in Excel
  • Splitting data with Excel text functions