EXCEL & DATA ANALYSIS

How to Clean Data in Excel: Spaces, Duplicates and Text

Learn practical Excel data-cleaning techniques using TRIM, CLEAN, Find and Replace, Remove Duplicates and Text to Columns.

Student learning resource9 min read

Messy spreadsheet data can break lookups, inflate counts and distort reports. Common issues include extra spaces, inconsistent labels, duplicate records, mixed date formats and numbers stored as text. A reliable cleaning process starts with preserving the original data and defining what counts as a duplicate or an invalid value.

Make a safe copy and inspect the data

Duplicate the original worksheet or file before cleaning. Review headers, row counts, blank cells, data types and a sample of records. Decide what each column is supposed to contain before making changes.

Do not automatically delete every repeated value. Two people can legitimately share a name, and two transactions can have the same amount. A duplicate should be defined using the business key or combination of fields that identifies one record.

  • Keep an untouched source copy.
  • Record the number of rows before and after cleaning.
  • Define the correct format for each column.
  • Confirm the key used to identify duplicate records.

Remove extra spaces and nonprinting characters

TRIM removes leading and trailing spaces and reduces repeated ordinary spaces between words. CLEAN removes many nonprinting characters. Depending on the data source, some unusual Unicode spaces may require an additional cleanup step.

Use a helper column first, compare cleaned values with the original, and only replace the original data after verifying the result.

=TRIM(A2)
=CLEAN(A2)
=TRIM(CLEAN(A2))

Find and handle duplicates carefully

Excel's Remove Duplicates command can remove rows based on the columns you select. Before using it, determine whether duplicate rows are genuine copies or repeated real events. A unique transaction ID is usually a better key than a person name alone.

For a safer audit, add a helper column that counts occurrences of a key, review rows with counts greater than one, and then decide which records should remain.

=COUNTIF($A$2:$A$100,A2)

Standardize text, dates and numbers

Find and Replace can standardize known variations, such as inconsistent department names, but it should be used carefully with a preview and a backup. Text to Columns can split a delimited field into separate columns, such as a last name and first name or a code and description.

A date that looks like 10/11/2026 can mean different things in different locales. Check the source format and intended locale before converting dates. Likewise, leading zeros in IDs may be meaningful and should not be removed just because an ID looks numeric.

  • Standardize category labels before grouping.
  • Convert numbers stored as text only after verifying intent.
  • Preserve leading zeros in codes where they are meaningful.
  • Use Text to Columns on a copy or with a clear undo path.

Validate the cleaned data

Cleaning is not complete until the output is checked. Compare row counts, total amounts, missing values and key uniqueness before and after the changes. Investigate unexpected changes instead of assuming fewer rows means better data.

For recurring workbooks, turn your cleaning steps into a documented repeatable process. If the process is complex or repeated often, Excel Power Query can make transformations easier to refresh and audit.

  • Check the row count and key uniqueness.
  • Compare totals before and after cleaning.
  • Review a sample of changed records.
  • Document rules and exceptions.
  • Keep the original file and record the transformation steps.
KEEP LEARNING

Understanding the concept is the first step.

Explore related resources or learn about subject-focused tutoring designed to help you understand the material.