Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Analysis and Reporting with Excel  ›  Lesson

Cleaning Text: TRIM, Case, CONCAT and SUBSTITUTE

REPLACE / SUBSTITUTE 15 minText functions tidy messy entries: TRIM removes extra spaces, UPPER, LOWER and PROPER fix case, CONCAT joins pieces, and REPLACE and SUBSTITUTE swap characters.

Cleaning Text: TRIM, Case, CONCAT and SUBSTITUTE

The loyalty sign-up form lets customers type their own names, and it shows. The sheet has " mEERA iyer ", "ASHA RAO" and "dev menon", and phone numbers written as 98450-12345. None of these will match the orders sheet in a lookup. Spreadsheet text functions fix them in bulk, without retyping a single name. On this sign-up sheet, names are in column C and phone numbers in column D; Meera is on row 4.

The rule

Trim the edges, fix the case, swap what's wrong, then join.

1. TRIM removes spaces at the start and end, and squeezes every run of spaces inside down to one. =TRIM(" mEERA iyer ") → "mEERA iyer"

2. Case functions make capitals consistent:

  • =UPPER("dev menon") → "DEV MENON"
  • =LOWER("ASHA RAO") → "asha rao"
  • =PROPER("mEERA iyer") → "Meera Iyer", capital first letter of each word, the rest lower-case.

3. Swapping characters comes in two flavours:

  • SUBSTITUTE(text, old, new) swaps by content: every copy of old becomes new. =SUBSTITUTE("98450-12345", "-", "") → "9845012345". It is case-sensitive.
  • REPLACE(text, start, count, new) swaps by position: starting at character start, remove count characters and insert new. =REPLACE("C01", 1, 1, "K") → "K01".

4. CONCAT joins pieces end to end with nothing between them, so add any separator yourself. The & operator does the same job. On the orders sheet: =CONCAT(D2, "-", A2) → "C01-1001", the same as =D2 & "-" & A2.

Functions nest, and the innermost one runs first: =PROPER(TRIM(C4)) trims, then fixes case.

The shortcut

Ask one question to pick the swapping function: "Do I know what to change, or where it is?" What → SUBSTITUTE. Where → REPLACE. Then build the formula from the inside out, in the rule's order.

Cleaning " mEERA iyer "Step 1 of 4
  1. Trim

    TRIM gives "mEERA iyer": no edge spaces, one space in the middle.

The trap: text that looks identical but is not. "Asha Rao " with a trailing space fails an exact lookup against "Asha Rao". When a lookup returns #N/A for a value you can see, TRIM first.

Drills

Answer fast — trust the rule.

quick drill

What does =TRIM(" Dev Menon ") return?

quick drill

What does =PROPER("vIKRAM sHAH") return?

quick drill

Every order code "B02" must become "P02" wherever it appears in a long note. Which function fits best?

quick drill

What does =CONCAT("Order", A2) return when A2 holds 1001?

quick drill

What does =REPLACE("2025-06-02", 1, 4, "2024") return?

Remember

  • Trim the edges, fix the case, swap what's wrong, then join.
  • Shortcut: know what to change → SUBSTITUTE; know where → REPLACE.
  • Trap: invisible trailing spaces break exact matches. TRIM before you look up.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainTidy a customer name

A customer name was typed as ' mEERA iyer ' in C4. Write one formula that returns 'Meera Iyer', and explain the order you applied the functions in. Then explain when you would use SUBSTITUTE rather than REPLACE.