Excel Tutorial menu

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

text
=A2&" "&B2
=CONCAT(A2, " ", B2)
ABResult
AyeshaSiddiquiAyesha Siddiqui
AliRazaAli Raza

TEXTJOIN joins a whole range with a separator and can skip empty cells:

Example

text
=TEXTJOIN(", ", TRUE, A2:A5)
A2:A5Result
Karachi, Lahore, (empty), QuettaKarachi, Lahore, Quetta

Older versions of Excel (2016 and before) use CONCATENATE instead of CONCAT, and do not have TEXTJOIN.

Changing Case

Example

text
=UPPER(A2)
=LOWER(A2)
=PROPER(A2)
A2UPPERLOWERPROPER
ali RAZAALI RAZAali razaAli 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

text
=TRIM(A2)
=LEN(A2)
=LEN(TRIM(A2))
A2LEN(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

FunctionWhat 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

text
=LEFT(A2, 3)
=MID(A2, 5, 4)
=RIGHT(A2, 4)
A2CityYearNumber
KHI-2026-0147KHI20260147
LHR-2025-0032LHR20250032

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

text
=FIND(" ", A2)
=LEFT(A2, FIND(" ", A2)-1)
A2FIND(" ", A2)First name
Hamza Ali6Hamza
Ayesha Siddiqui7Ayesha

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

text
=SUBSTITUTE(A2, "-", "")
A2Result
0300-123456703001234567

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

text
="Total: Rs "&TEXT(B2, "#,##0")
="Date: "&TEXT(C2, "dd-mmm-yyyy")
B2C2Results
12500015/10/2026Total: 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"?

Learn Excel with a teacher

Join the CIT (Computer Information Technology) course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp