Excel Text Functions
Text functions let you join, cut, clean and change text, which is very useful when data comes from forms or other systems.
Joining Text
Use & or the CONCAT function to join text from several cells:
Example
=A2&" "&B2
=CONCAT(A2, " ", B2)| A | B | Result |
|---|---|---|
| Ayesha | Siddiqui | Ayesha Siddiqui |
| Ali | Raza | Ali Raza |
TEXTJOIN joins a whole range with a separator and can skip empty cells:
Example
=TEXTJOIN(", ", TRUE, A2:A5)| A2:A5 | Result |
|---|---|
| Karachi, Lahore, (empty), Quetta | Karachi, Lahore, Quetta |
Older versions of Excel (2016 and before) use CONCATENATE instead of CONCAT, and do not have TEXTJOIN.
Changing Case
Example
=UPPER(A2)
=LOWER(A2)
=PROPER(A2)| A2 | UPPER | LOWER | PROPER |
|---|---|---|---|
| ali RAZA | ALI RAZA | ali raza | Ali Raza |
PROPER is great for fixing names typed in all capitals or all small letters.
Cleaning Extra Spaces
Data from forms often has extra spaces that you cannot see but that break lookups and comparisons. TRIM removes spaces at the start and end and turns double spaces into single ones:
Example
=TRIM(A2)
=LEN(A2)
=LEN(TRIM(A2))| A2 | LEN(A2) | TRIM(A2) | LEN(TRIM(A2)) |
|---|---|---|---|
| " Sana Khan " | 14 | "Sana Khan" | 9 |
LEN counts characters, including spaces. Comparing LEN before and after TRIM shows if a cell had extra spaces.
Cutting Out Part of the Text
| Function | What it returns |
|---|---|
LEFT(text, n) | The first n characters |
RIGHT(text, n) | The last n characters |
MID(text, start, n) | n characters starting at position start |
Student roll numbers look like KHI-2026-0147:
Example
=LEFT(A2, 3)
=MID(A2, 5, 4)
=RIGHT(A2, 4)| A2 | City | Year | Number |
|---|---|---|---|
| KHI-2026-0147 | KHI | 2026 | 0147 |
| LHR-2025-0032 | LHR | 2025 | 0032 |
Finding Text
FIND gives the position of some text inside another text. Combined with LEFT, it can take the first name from a full name, whatever its length:
Example
=FIND(" ", A2)
=LEFT(A2, FIND(" ", A2)-1)| A2 | FIND(" ", A2) | First name |
|---|---|---|
| Hamza Ali | 6 | Hamza |
| Ayesha Siddiqui | 7 | Ayesha |
FIND is case sensitive; SEARCH works the same way but ignores case.
Replacing Text
SUBSTITUTE replaces some text with other text. Remove dashes from phone numbers:
Example
=SUBSTITUTE(A2, "-", "")| A2 | Result |
|---|---|
| 0300-1234567 | 03001234567 |
Formatting Numbers as Text
TEXT turns a number or date into text in the format you choose, so you can join it into a sentence:
Example
="Total: Rs "&TEXT(B2, "#,##0")
="Date: "&TEXT(C2, "dd-mmm-yyyy")| B2 | C2 | Results |
|---|---|---|
| 125000 | 15/10/2026 | Total: Rs 125,000 and Date: 15-Oct-2026 |
Flash Fill
For simple patterns you do not even need a formula. Type the result you want for the first row (for example the first name), go to the next cell and press Ctrl + E. Excel's Flash Fill guesses the pattern and fills the rest of the column. Check the result, because it can guess wrong.
Exercise
Exercise
Cell A2 contains "PK-9087". Which formula returns "9087"?
