Templates, guides & honest tool reviews for small business

Sunday, November 29, 2026

Clean Data in Excel with ChatGPT: Practical Prompts and Formulas

Clean data in Excel with ChatGPT: practical prompts
Illustration: Clean data in Excel with ChatGPT

Messy data is the most common spreadsheet problem, and you can use an AI chatbot such as ChatGPT to clean data in Excel faster. The safest way is to ask the chatbot for a formula or a short step list, then test it on a few rows yourself. This guide gives practical prompts for removing extra spaces, fixing names, splitting columns, fixing dates and finding duplicates, with made-up examples. It uses the chat window, not any special Excel add-in.

Rule one: describe the data, do not paste private data

Describe your columns and show two or three fake sample rows. Do not paste customer names, phone numbers or financial records into a chatbot unless your company allows it. A good prompt contains the column letters, an example of the bad value and an example of the result you want.

Excel TRIM formula from a ChatGPT prompt to remove extra spaces
Made-up names (illustration).

Remove extra spaces

Prompt: "In Excel, column A has names with extra spaces at the start, end and between words, like ' Sara Ahmed '. Give me a formula that cleans one cell."

The answer you should expect is the TRIM function:

=TRIM(A2)

TRIM removes spaces at the start and end and reduces repeated spaces between words to one. If the spaces come from a web page, they may be non-breaking spaces, which TRIM does not remove. Ask the chatbot: "TRIM does not remove the spaces, they may be CHAR(160). What formula fixes it?" The usual answer is =TRIM(SUBSTITUTE(A2, CHAR(160), " ")).

Fix capital letters in names

Prompt: "Column A has names in mixed case like 'sARA aHMED'. Give me an Excel formula to make each word start with a capital letter."

=PROPER(TRIM(A2))

Check names such as McDonald or al-Masri by hand, because PROPER will turn them into Mcdonald and Al-Masri.

Split one column into two

Prompt: "Column A has 'Sara Ahmed'. Give me formulas for the first name and the last name."

The answer should use LEFT, RIGHT, FIND and LEN. We explain each part in our guide to the LEFT, RIGHT and MID functions in Excel.

Excel DATEVALUE formula to turn text dates into real dates
Dates stored as text (illustration).

Fix text dates

Prompt: "Column B has dates stored as text like '2026-11-05'. Give me a formula to turn them into real Excel dates."

=DATEVALUE(B2)

Then format the result as a date. If DATEVALUE returns an error, your regional settings may not read that format. Tell the chatbot your date format and your region and ask again.

Excel COUNTIF formula to mark duplicate rows
Helper column with a flag (illustration).

Find duplicates

Prompt: "In Excel, mark rows where the value in column A appears more than once."

=IF(COUNTIF($A$2:$A$100, A2) > 1, "Duplicate", "")

You can then filter the helper column. For the counting part, see COUNTIFS with multiple criteria.

Replace errors

When a clean-up formula returns an error for some rows, wrap it as the chatbot suggests, and understand why before you accept it. Our IFERROR guide explains when this is safe.

How to test an AI-written formula in Excel before filling it down
Five steps before you trust a result (illustration).

How to test an AI formula

  1. Copy the formula into a spare column, not over your data.
  2. Try it on five rows, including the strangest ones.
  3. Compare the result with what you expected.
  4. Only then fill it down the whole column.
  5. Keep the original column until you are sure.

For another ChatGPT use case, see how to use ChatGPT to write Excel formulas.

Common mistakes

  • Vague prompts. "Clean my data" gets a vague answer. Name the column and show an example.
  • Wrong function names. Chatbots sometimes invent functions or use ones missing from your Excel version. If Excel says the name is not valid, ask for a version that works in your Excel.
  • Skipping the test. A formula can look right and still fail on blank cells.

Questions and answers

Can ChatGPT clean the file for me directly?

Some versions of chatbots can read an uploaded file, but features differ by plan and change often. Check what your plan offers before you rely on it, and think about whether the file contains private data.

Is Power Query better for cleaning?

For repeated, large clean-ups, yes, because it saves the steps. A chatbot can help you decide which steps to use.

Will the formulas work in Google Sheets?

TRIM, PROPER, SUBSTITUTE, LEFT, RIGHT and COUNTIF exist in both. Ask the chatbot to write for the tool you use.

Summary

Describe the column, give an example of bad and good values, test the formula on a few rows, and keep your original data until the result is checked.

العربية