Courses Learn Blog Contact
Get Started →
Lesson 8

Week 2, Live 2: Cleaning Text With TRIM, PROPER, UPPER, LOWER, CLEAN, FIND and SUBSTITUTE

Fix spaces, case and hidden characters, find a character inside text, replace part of it, and combine them in one formula.

Webbo3 Data Analytics Cohort 2: Excel Track 24 min read Free

Webbo3 Data Analytics · Cohort 2 · Excel Track · Week 2, Live 2

Cleaning Text With TRIM, PROPER, UPPER, LOWER, CLEAN, FIND and SUBSTITUTE

Last class, LEN proved the spaces were there. Today you remove them, fix the capital letters, strip out invisible characters, and find and replace pieces of text: Steps 6 and 7 of the Cleaning Process.

By the end of this class you can

  • Remove stray spaces with TRIM and confirm it with LEN
  • Fix capital letters with PROPER, UPPER and LOWER, and know when PROPER does damage
  • Remove invisible characters with CLEAN
  • Combine cleaning functions in one formula and read it from the inside out
  • Locate a character with FIND and replace text with SUBSTITUTE

Chidi Okonkwo works at Lagos Island. In the Sales Data sheet his name is typed 9 different ways: CHIDI OKONKWO, chidi okonkwo, and the same with spaces before or after. To Excel those are different people. Today's functions make every one of them say exactly what it means.

Start from Sales Data after Steps 3 to 5 (duplicates removed, Unknown filled in). One rule for the whole class: a cleaning function never changes the original cell. It writes a cleaned copy in a new column. You check the copy, and only then replace the original (Step 8, in Virtual 2).

1. The Cleaning Functions

Definition

Five functions each fix one kind of text problem. Each takes one cell and returns a cleaned copy of its text.

Real-Life Scenario

Name tags at a wedding, written by ten different ushers. One wrote in capitals, one in small letters, one left a big gap before the name, one wrote on a crumpled card. Before the tags go on the seating chart, somebody rewrites them neatly, the same way. These functions are that somebody.

The Five Functions

FunctionFixesExample
TRIMSpaces at the start and end, and runs of spaces in the middle" Chidi Okonkwo " becomes "Chidi Okonkwo"
PROPERCapitals: first letter of every word up, the rest down"CHIDI OKONKWO" becomes "Chidi Okonkwo"
UPPEREverything in capitals"Kano" becomes "KANO"
LOWEREverything in small letters"KANO" becomes "kano"
CLEANInvisible characters such as line breaks, often left by copying from WhatsApp, email or a web page"Kano" followed by a line break becomes "Kano"

Function 1: TRIM (Step 6)

Step 6 of the Cleaning Process

1.Right-click the column letter J (Branch) › Insert › A new empty column appears; Branch moves to K
2.Type Staff_Clean in J1 › In J2 type =TRIM(I2) › Enter › Double-click the fill handle

TRIM removes every space at the start and end of the text, and squeezes any run of spaces in the middle down to one. It leaves single spaces between words alone, so "Chidi Okonkwo" keeps its space.

What this formula doesWe want a copy of every Staff_Name with the stray spaces removed, here on the rows where Chidi Okonkwo's name is typed differently.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
J20
fx
=TRIM(I20)
A⋯IJ
1Transaction_IDStaff_NameStaff_Clean
⋮⋮⋮⋮
20TP-0724chidi okonkwochidi okonkwo
⋮⋮⋮⋮
26TP-0680Chidi OkonkwoChidi Okonkwo
⋮⋮⋮⋮
29TP-0553CHIDI OKONKWOCHIDI OKONKWO
⋮⋮⋮⋮
189TP-0592··Chidi·OkonkwoChidi Okonkwo
⋮⋮⋮⋮
332TP-0127··Chidi·Okonkwo···Chidi Okonkwo
⋮⋮⋮⋮
339TP-0326···Chidi·OkonkwoChidi Okonkwo
⋮⋮⋮⋮
403TP-0273···Chidi·Okonkwo···Chidi Okonkwo
Filled down from J2 to J1051: 1,050 rows. Rows 20, 26, 29, 189, 332, 339, 403 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

The red dots are gone. But look at the capital letters: "CHIDI OKONKWO" and "chidi okonkwo" are still different from "Chidi Okonkwo". TRIM does one job only.

What this formula doesWe want proof that TRIM worked: the length of each trimmed value.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N20
fx
=LEN(J20)
I⋯N
1Staff_NameTrim_Length
⋮⋮⋮
20chidi okonkwo13
⋮⋮⋮
26Chidi Okonkwo13
⋮⋮⋮
29CHIDI OKONKWO13
⋮⋮⋮
189··Chidi·Okonkwo13
⋮⋮⋮
332··Chidi·Okonkwo···13
⋮⋮⋮
339···Chidi·Okonkwo13
⋮⋮⋮
403···Chidi·Okonkwo···13
Filled down from N2 to N1051: 1,050 rows. Rows 20, 26, 29, 189, 332, 339, 403 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Every version is now 13 characters, the length of "Chidi Okonkwo". LEN is how you prove a clean, not just how you hope for one.

Function 2: PROPER

What this formula doesWe want every Staff_Name with a capital first letter on each word and small letters after it.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
J20
fx
=PROPER(I20)
A⋯IJ
1Transaction_IDStaff_NameStaff_Clean
⋮⋮⋮⋮
20TP-0724chidi okonkwoChidi Okonkwo
⋮⋮⋮⋮
26TP-0680Chidi OkonkwoChidi Okonkwo
⋮⋮⋮⋮
29TP-0553CHIDI OKONKWOChidi Okonkwo
⋮⋮⋮⋮
189TP-0592··Chidi·Okonkwo··Chidi·Okonkwo
⋮⋮⋮⋮
332TP-0127··Chidi·Okonkwo·····Chidi·Okonkwo···
⋮⋮⋮⋮
339TP-0326···Chidi·Okonkwo···Chidi·Okonkwo
⋮⋮⋮⋮
403TP-0273···Chidi·Okonkwo······Chidi·Okonkwo···
Filled down from J2 to J1051: 1,050 rows. Rows 20, 26, 29, 189, 332, 339, 403 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

The capitals are fixed, but the red dots are back: PROPER does not touch spaces. You need both functions, and section 2 puts them together.

Where PROPER Does Damage

PROPER capitalises the first letter after anything that is not a letter, and lowers everything else. For people's names and places that is perfect. For product names full of brands and abbreviations, it is not. Here is what it does to the twenty products in the catalogue:

What this formula doesWe want to see what PROPER does to every product name, one row per product.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=PROPER(D2)
D⋯M
1Product_NameProper_Product
2Thermocool AC 1.5HPThermocool Ac 1.5Hp
3Infinix Hot 40Infinix Hot 40
4Anker Power Bank 20KAnker Power Bank 20K
5Samsung 43" TVSamsung 43" Tv
6Logitech Wireless MouseLogitech Wireless Mouse
⋮⋮⋮
8JBL Bluetooth SpeakerJbl Bluetooth Speaker
⋮⋮⋮
10Acer Aspire 5Acer Aspire 5
11Dell Inspiron 15Dell Inspiron 15
12Tecno Spark 20Tecno Spark 20
13Hisense 50" TVHisense 50" Tv
14TP-Link WiFi RouterTp-Link Wifi Router
15Lenovo IdeaPad 3Lenovo Ideapad 3
⋮⋮⋮
19HP Laptop 15Hp Laptop 15
20Sony 55" TVSony 55" Tv
⋮⋮⋮
22LG Washing MachineLg Washing Machine
⋮⋮⋮
32iPhone 14Iphone 14
⋮⋮⋮
36LG 32" TVLg 32" Tv
⋮⋮⋮
43Scanfrost Fridge 200LScanfrost Fridge 200L
⋮⋮⋮
61Sumec Generator 3.5KVASumec Generator 3.5Kva
⋮⋮⋮
71Samsung Galaxy A54Samsung Galaxy A54
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 19, 20, 22, 32, 36, 43, 61, 71 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

12 of the 20 names come out wrong: iPhone becomes Iphone, HP becomes Hp, TV becomes Tv, TP-Link WiFi becomes Tp-Link Wifi. The product names were already right. That is why the Cleaning Process tab names exactly four columns to clean (Staff_Name, Branch, Category, Customer_Type) and never says "the whole sheet". Use PROPER only on a column that needs it.

Function 3: UPPER

What this formula doesWe want every Staff_Name in capitals, the way a printed badge shows it.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
J2
fx
=UPPER(I2)
A⋯IJ
1Transaction_IDStaff_NameStaff_Clean
2TP-0892Aisha MusaAISHA MUSA
3TP-0785fatima garbaFATIMA GARBA
4TP-0210fatima garbaFATIMA GARBA
5TP-0343··aisha·musa··AISHA·MUSA
6TP-0238··Tunde·Bello··TUNDE·BELLO
7TP-0474···EMEKA·NWOSU···EMEKA·NWOSU
Filled down from J2 to J1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 7 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Every value is in capitals now, but the spaces are still there. UPPER is useful when a system expects capitals (codes, labels, IDs) or when you want two spellings to compare equal regardless of case.

Function 4: LOWER

What this formula doesWe want every Staff_Name in small letters.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
J2
fx
=LOWER(I2)
A⋯IJ
1Transaction_IDStaff_NameStaff_Clean
2TP-0892Aisha Musaaisha musa
3TP-0785fatima garbafatima garba
4TP-0210fatima garbafatima garba
5TP-0343··aisha·musa··aisha·musa
6TP-0238··Tunde·Bello··tunde·bello
7TP-0474···EMEKA·NWOSU···emeka·nwosu
Filled down from J2 to J1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 7 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

LOWER is the mirror of UPPER. You will use it less in reports, but it is the standard choice for email addresses and usernames, which systems usually expect in small letters.

Function 5: CLEAN

Some characters cannot be seen at all. Copy a name out of a WhatsApp message or an email and you may bring a line break or a tab with it. CLEAN removes those non-printing characters. To show it, here are three branch names pasted from a message, with the invisible characters drawn in red: a line break (↵), a tab (→) and both.

What this formula doesWe want to see how long each pasted value is before cleaning.
XBook1 - Excel
After Enter and Fill Down
B2
fx
=LEN(A2)
AB
1PastedLength
2Kano↵5
3→Warri6
4Jos↵→5
Filled down from B2 to B4: 3 rows. Rows 2, 3, 4 shown.
Sheet1
What this formula doesWe want each pasted value with its invisible characters removed.
XBook1 - Excel
After Enter and Fill Down
C2
fx
=CLEAN(A2)
A⋯C
1PastedCleaned
2Kano↵Kano
3→WarriWarri
4Jos↵→Jos
Filled down from C2 to C4: 3 rows. Rows 2, 3, 4 shown.
Sheet1
One Invisible Character CLEAN Misses

Text copied from a web page often contains a non-breaking space, which looks exactly like a space. Neither TRIM nor CLEAN removes it. If LEN still shows an extra character after TRIM(CLEAN()), that is usually the reason, and SUBSTITUTE (section 4) is the fix.

Picture This

Picture the wedding usher with five pens: one rubs out extra gaps (TRIM), one fixes capitals (PROPER), one writes in capitals (UPPER), one in small letters (LOWER), and one irons the crumpled card (CLEAN). Each pen does one thing.

2. Combining Text Functions (Step 7)

Definition

You can put one function inside another, so the result of the inner one becomes the input of the outer one. This is called nesting. Excel always works from the inside out.

Real-Life Scenario

Washing clothes, then ironing them. The iron works on whatever comes out of the washing machine. You write the instruction as "iron (wash (shirt))", and it happens wash first, iron second.

How Excel Reads It

In =PROPER(TRIM(I2)), Excel first works out TRIM(I2), which removes the spaces, then hands that result to PROPER, which fixes the capitals. One formula, two fixes. The brackets must match: every opening bracket needs a closing one, and the formula bar colours each pair while you type to help you.

Step 7 of the Cleaning Process

1.Click J2 › Change the formula to =PROPER(TRIM(I2)) › Enter › Double-click the fill handle
What this formula doesWe want every Staff_Name fixed for spaces and capitals at once: CHIDI OKONKWO and chidi okonkwo should both become Chidi Okonkwo.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
J20
fx
=PROPER(TRIM(I20))
A⋯IJ
1Transaction_IDStaff_NameStaff_Clean
⋮⋮⋮⋮
20TP-0724chidi okonkwoChidi Okonkwo
⋮⋮⋮⋮
26TP-0680Chidi OkonkwoChidi Okonkwo
⋮⋮⋮⋮
29TP-0553CHIDI OKONKWOChidi Okonkwo
⋮⋮⋮⋮
189TP-0592··Chidi·OkonkwoChidi Okonkwo
⋮⋮⋮⋮
332TP-0127··Chidi·Okonkwo···Chidi Okonkwo
⋮⋮⋮⋮
339TP-0326···Chidi·OkonkwoChidi Okonkwo
⋮⋮⋮⋮
403TP-0273···Chidi·Okonkwo···Chidi Okonkwo
Filled down from J2 to J1051: 1,050 rows. Rows 20, 26, 29, 189, 332, 339, 403 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Every version of Chidi's name is now Chidi Okonkwo. Filter Staff_Clean and you will see exactly 10 names, the ten people in the Staff Directory. The order of the two functions does not matter here; =TRIM(PROPER(I2)) gives the same result, because neither undoes the other.

The Same Fix on the Other Columns

Step 9 of the Cleaning Process repeats this on Branch, Category and Customer_Type. Category is the interesting one: its only problem is capitals, so TRIM finds nothing to do, and PROPER does all the work:

What this formula doesWe want every Category written as one of the five real categories.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=PROPER(TRIM(E2))
A⋯E⋯M
1Transaction_IDCategoryCategory_Clean
2TP-0892AppliancesAppliances
3TP-0785SMARTPHONESSmartphones
4TP-0210AccessoriesAccessories
5TP-0343TelevisionsTelevisions
⋮⋮⋮⋮
7TP-0474TELEVISIONSTelevisions
8TP-0162accessoriesAccessories
⋮⋮⋮⋮
10TP-0207LaptopsLaptops
⋮⋮⋮⋮
14TP-0921ACCESSORIESAccessories
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 7, 8, 10, 14 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Five categories, exactly as the Cleaning Process tab promises in Step 10: Accessories, Appliances, Laptops, Smartphones, Televisions.

Try This

Write =UPPER(TRIM(K2)) beside the Branch column (K, after your inserted column). Then write =LEN(UPPER(TRIM(K2))) next to it. Which branch has the longest name?

Check your answer

LAGOS MAINLAND, at 14 characters.

Picture This

Picture the washing machine and the iron: the shirt goes in crumpled and stained, comes out of the machine clean but creased, and comes off the board ready to wear. PROPER(TRIM()) is the same journey, read from the inside out.

3. FIND

Definition

FIND(what, text) returns the position of the first place what appears inside text, counting from 1. It is how you stop guessing positions for LEFT and MID.

Real-Life Scenario

A list where each line is "Firstname Surname". To split it you do not count letters: you look for the space, and everything before it is the first name. FIND looks for the space for you.

Example 1: Where Is the First Space?

What this formula doesWe want the position of the first space in each product name.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=FIND(" ",D2)
D⋯M
1Product_NameSpace_At
2Thermocool AC 1.5HP11
3Infinix Hot 408
4Anker Power Bank 20K6
5Samsung 43" TV8
6Logitech Wireless Mouse9
⋮⋮⋮
8JBL Bluetooth Speaker4
⋮⋮⋮
10Acer Aspire 55
11Dell Inspiron 155
12Tecno Spark 206
13Hisense 50" TV8
14TP-Link WiFi Router8
15Lenovo IdeaPad 37
⋮⋮⋮
19HP Laptop 153
20Sony 55" TV5
⋮⋮⋮
22LG Washing Machine3
⋮⋮⋮
32iPhone 147
⋮⋮⋮
36LG 32" TV3
⋮⋮⋮
43Scanfrost Fridge 200L10
⋮⋮⋮
61Sumec Generator 3.5KVA6
⋮⋮⋮
71Samsung Galaxy A548
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 19, 20, 22, 32, 36, 43, 61, 71 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

In "Samsung Galaxy A54" the space is character 8, so the first word is the 7 characters before it. In "HP Laptop 15" it is character 3. The position changes; FIND finds it each time.

Example 2: FIND Inside LEFT, the First Word of Every Product

Combine it with LEFT. We want everything before the space, which is the space's position minus 1 characters:

What this formula doesWe want the first word of every product name, whatever its length.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=LEFT(D2,FIND(" ",D2)-1)
D⋯M
1Product_NameFirst_Word
2Thermocool AC 1.5HPThermocool
3Infinix Hot 40Infinix
4Anker Power Bank 20KAnker
5Samsung 43" TVSamsung
6Logitech Wireless MouseLogitech
⋮⋮⋮
8JBL Bluetooth SpeakerJBL
⋮⋮⋮
10Acer Aspire 5Acer
11Dell Inspiron 15Dell
12Tecno Spark 20Tecno
13Hisense 50" TVHisense
14TP-Link WiFi RouterTP-Link
15Lenovo IdeaPad 3Lenovo
⋮⋮⋮
19HP Laptop 15HP
20Sony 55" TVSony
⋮⋮⋮
22LG Washing MachineLG
⋮⋮⋮
32iPhone 14iPhone
⋮⋮⋮
36LG 32" TVLG
⋮⋮⋮
43Scanfrost Fridge 200LScanfrost
⋮⋮⋮
61Sumec Generator 3.5KVASumec
⋮⋮⋮
71Samsung Galaxy A54Samsung
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 19, 20, 22, 32, 36, 43, 61, 71 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

For most products the first word is the brand. Not for all: compare with the Brand column of the Product Catalogue tab, and 1 disagree, such as iPhone 14, whose brand is Apple. A formula that cuts text can only find what is written; it cannot know what is meant. In Week 4 you will fetch the real brand from the catalogue with XLOOKUP instead.

When FIND Finds Nothing

What this formula doesWe want to see what FIND returns when the thing it looks for is not in the text: a hyphen, in names that mostly have none.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=FIND("-",D2)
D⋯M
1Product_NameHyphen_At
2Thermocool AC 1.5HP#VALUE!
3Infinix Hot 40#VALUE!
4Anker Power Bank 20K#VALUE!
5Samsung 43" TV#VALUE!
6Logitech Wireless Mouse#VALUE!
⋮⋮⋮
8JBL Bluetooth Speaker#VALUE!
⋮⋮⋮
10Acer Aspire 5#VALUE!
11Dell Inspiron 15#VALUE!
12Tecno Spark 20#VALUE!
13Hisense 50" TV#VALUE!
14TP-Link WiFi Router3
15Lenovo IdeaPad 3#VALUE!
⋮⋮⋮
19HP Laptop 15#VALUE!
20Sony 55" TV#VALUE!
⋮⋮⋮
22LG Washing Machine#VALUE!
⋮⋮⋮
32iPhone 14#VALUE!
⋮⋮⋮
36LG 32" TV#VALUE!
⋮⋮⋮
43Scanfrost Fridge 200L#VALUE!
⋮⋮⋮
61Sumec Generator 3.5KVA#VALUE!
⋮⋮⋮
71Samsung Galaxy A54#VALUE!
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 19, 20, 22, 32, 36, 43, 61, 71 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Most rows show #VALUE!: Excel's way of saying "not found". Only TP-Link WiFi Router has a hyphen, at position 3. You will learn to catch errors like this neatly with IFERROR in Week 4.

FIND Cares About Capitals

FIND("p", D2) and FIND("P", D2) give different answers. If you want to ignore capitals, use SEARCH, which works the same way but treats "p" and "P" as one.

Picture This

Picture your finger running along a line of text and stopping at the first space. FIND is that finger, and it tells you how many letters it passed.

4. SUBSTITUTE

Definition

SUBSTITUTE(text, old, new) replaces every copy of old inside the text with new. To delete something, replace it with nothing: two double quotes with nothing between them, "".

Real-Life Scenario

Find and Replace in a document, but in a formula, so it works on every row at once and leaves the original untouched.

Example 1: Removing a Character

Suppose TechPlug moves to a new till system that rejects hyphens in transaction numbers.

What this formula doesWe want every Transaction_ID without its hyphen, ready for the new till system.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=SUBSTITUTE(A2,"-","")
A⋯M
1Transaction_IDNew_ID
2TP-0892TP0892
3TP-0785TP0785
4TP-0210TP0210
5TP-0343TP0343
6TP-0238TP0238
7TP-0474TP0474
8TP-0162TP0162
9TP-0962TP0962
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 7, 8, 9 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Example 2: Replacing an Awkward Character

Four TV names use the inch mark, a double quote: Samsung 43" TV. That character causes trouble in CSV files and text messages. You cannot simply type it inside a formula's quotes, so Excel gives it a code: CHAR(34) is the double quote character.

What this formula doesWe want every inch mark in the product names written as the word "inch" instead.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=SUBSTITUTE(D2,CHAR(34)," inch")
D⋯M
1Product_NameLabel_Name
2Thermocool AC 1.5HPThermocool AC 1.5HP
3Infinix Hot 40Infinix Hot 40
4Anker Power Bank 20KAnker Power Bank 20K
5Samsung 43" TVSamsung 43 inch TV
6Logitech Wireless MouseLogitech Wireless Mouse
⋮⋮⋮
8JBL Bluetooth SpeakerJBL Bluetooth Speaker
⋮⋮⋮
10Acer Aspire 5Acer Aspire 5
11Dell Inspiron 15Dell Inspiron 15
12Tecno Spark 20Tecno Spark 20
13Hisense 50" TVHisense 50 inch TV
14TP-Link WiFi RouterTP-Link WiFi Router
15Lenovo IdeaPad 3Lenovo IdeaPad 3
⋮⋮⋮
19HP Laptop 15HP Laptop 15
20Sony 55" TVSony 55 inch TV
⋮⋮⋮
22LG Washing MachineLG Washing Machine
⋮⋮⋮
32iPhone 14iPhone 14
⋮⋮⋮
36LG 32" TVLG 32 inch TV
⋮⋮⋮
43Scanfrost Fridge 200LScanfrost Fridge 200L
⋮⋮⋮
61Sumec Generator 3.5KVASumec Generator 3.5KVA
⋮⋮⋮
71Samsung Galaxy A54Samsung Galaxy A54
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 19, 20, 22, 32, 36, 43, 61, 71 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

"Samsung 43" TV" becomes "Samsung 43 inch TV". Every name without an inch mark comes back unchanged. No errors, no damage: SUBSTITUTE is safe to run on a whole column.

SUBSTITUTE Also Cares About Capitals

SUBSTITUTE(D2,"tv","television") would change nothing here, because the names say "TV" in capitals. Match the text exactly.

And the fix from the CLEAN note: =TRIM(SUBSTITUTE(I2,CHAR(160)," ")) turns every non-breaking space into an ordinary space, then TRIM tidies up. CHAR(160) is the code for that invisible character.

Picture This

Picture a teacher marking a stack of essays with one instruction: "everywhere you see this mark, write inch". She does not reread the essays; she just scans for that one mark.

Overall Example: A First Name for Every Sale

One new symbol first. The ampersand, &, joins pieces of text into one: ="Well done, "&"Chidi" gives Well done, Chidi. TechPlug wants a thank-you line for each salesperson, using only their first name:

What this formula doesWe want a thank-you line with the salesperson's first name, built from their cleaned name in J.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N5
fx
="Well done, "&LEFT(J5,FIND(" ",J5)-1)&"!"
IJ⋯N
1Staff_NameStaff_CleanGreeting
⋮⋮⋮⋮
5··aisha·musaAisha MusaWell done, Aisha!
6··Tunde·BelloTunde BelloWell done, Tunde!
7···EMEKA·NWOSUEmeka NwosuWell done, Emeka!
⋮⋮⋮⋮
20chidi okonkwoChidi OkonkwoWell done, Chidi!
⋮⋮⋮⋮
26Chidi OkonkwoChidi OkonkwoWell done, Chidi!
⋮⋮⋮⋮
29CHIDI OKONKWOChidi OkonkwoWell done, Chidi!
⋮⋮⋮⋮
189··Chidi·OkonkwoChidi OkonkwoWell done, Chidi!
Filled down from N2 to N1051: 1,050 rows. Rows 5, 6, 7, 20, 26, 29, 189 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Read it from the inside out. FIND finds the space in the cleaned name, LEFT takes everything before it, and the ampersands join it to the words around it. It only works because J was trimmed first: on " chidi okonkwo" the first space is at position 1, and LEFT would hand back nothing.

Practical Exercises

Exercise 1: Very Easy

Use TRIM on the Branch column and check with LEN that "Kano" is 4 characters everywhere.

Exercise 2: Simple Application

Use =PROPER(TRIM(K2)) to clean Customer_Type (after your inserted column). Filter the result: how many different values do you see?

Exercise 3: Combination

Use FIND and MID to pull the second word of each staff name (the surname). Hint: start one character after the space.

Exercise 4: A Small Real-World Problem

A colleague cleaned Product_Name with PROPER "to be safe". Write two sentences for your pod chat explaining what went wrong and how to undo it.

Answers to the exercises

Exercise 2: four values, Corporate, Retail, Unknown and Wholesale. Exercise 3: =MID(J2,FIND(" ",J2)+1,LEN(J2)). Exercise 4: PROPER changed 12 correct names (iPhone, HP, TV and more); press Ctrl + Z, or paste the names back from the Raw Data tab.

Checkpoint

Q1. What does TRIM do to the space between "Chidi" and "Okonkwo"?

Nothing, if there is only one. It squeezes runs of spaces to one and removes spaces at the ends.

Q2. In =PROPER(TRIM(I2)), which function runs first?

TRIM. Excel works from the inside out.

Q3. Why does the Cleaning Process tab not say "run PROPER on every column"?

Because PROPER would damage 12 correct product names, such as iPhone 14 and HP Laptop 15.

Q4. =FIND("x","Kano") returns what?

#VALUE!, because there is no x in Kano.

Q5. Why insert a helper column instead of typing over the names?

So the original stays untouched until the cleaned copy is checked. Step 8 then replaces it with values.

Tick Before You Move On

  • ☐ I inserted a helper column next to Staff_Name, as Step 6 says
  • ☐ I can use TRIM and prove it worked with LEN
  • ☐ I can use PROPER, UPPER and LOWER and know where PROPER does damage
  • ☐ I can remove invisible characters with CLEAN
  • ☐ I can nest =PROPER(TRIM(I2)) and read it from the inside out
  • ☐ I can find a character with FIND and use it inside LEFT
  • ☐ I can replace text with SUBSTITUTE

Quick Recap

TRIM fixes spaces, PROPER, UPPER and LOWER fix capitals, CLEAN removes invisible characters. Nested functions run from the inside out: =PROPER(TRIM(I2)) removes spaces, then fixes capitals. PROPER damages brands and abbreviations, so use it only on the four columns that need it. FIND gives a position; inside LEFT or MID it replaces guessing. SUBSTITUTE replaces every copy of exact text, and is safe on a whole column.

Final Scenario

TechPlug's head office asks why Chidi Okonkwo's sales on last month's report are lower than his manager, Amaka Eze, says they should be.

You open Sales Data and filter Staff_Name. Chidi is there under 9 spellings. The filter groups the capitals together but not the spaces, so every sale typed with spaces around his name was left out of the report. You add =PROPER(TRIM(I2)), check it, and his total matches Amaka's figure to the Naira.

Clean text is not cosmetic. It decides which rows a total can see.

Next, Week 2, Virtual 2: Steps 8 to 10 on your own: paste the clean names back, repeat for Branch, Category and Customer_Type, and check your work. Then you open the Verdant Foods file.

Learn this with a real instructor

Free lessons take you a long way on your own. The full programmes add live classes, assignments, Skill Points and a certificate — built for African students.