Cleaning Messy Spreadsheet Data with AI: What to Automate and What to Check Yourself

TL;DR
  • Let AI write the transformation. Never let it be the transformation. A formula you can read and rerun is auditable; a block of pasted-back values is not.
  • Deterministic tasks are safe: trimming, substituting, splitting, case-fixing, standardising a known label list, generating a regex. The rule either fires or it does not.
  • Judgement tasks are risky: filling blanks, inferring a country from a city, repairing IDs, merging near-duplicates. The model has no source of truth, so it produces something plausible instead of nothing.
  • Verification is three checks: keep the raw column, reconcile COUNTA and COUNT before and after, and read the twenty ugliest rows yourself.

The one-sentence answer

Hand AI the cleaning jobs that have exactly one correct output for a given input — trimming whitespace, replacing a character, splitting on a delimiter, mapping a fixed list of labels — and keep for yourself the ones that require knowing something the data does not contain, because a language model responds to a missing fact by generating a convincing substitute rather than by admitting the gap. That single distinction, deterministic versus judgement, sorts nearly every data-cleaning task you will meet.

The rest of this article works through both sides of the line, then covers the verification habits that make the safe side genuinely safe.

Why the distinction is about mechanism, not model quality

This is not an argument that AI is unreliable and will improve. It is an argument about what the two modes of use actually produce.

When you ask for a formula, the output is a rule. You can read it, you can see what it does and does not touch, Excel applies it identically to row 4 and row 40,000, and if it is wrong it is wrong everywhere in the same visible way. Wrong rules announce themselves: a column of #VALUE! errors, or names that are obviously chopped in the wrong place.

When you paste 2,000 rows into a chat window and ask for them back cleaned, the output is text that resembles your data. There is no rule applied consistently, no mechanism that guarantees row 1,317 came back with the same digits it went in with, and no error state. Wrong values look exactly like right values. That is the entire risk, and it does not go away with a better model, because the failure is silent by construction rather than by accident.

Same goal, two very different mechanisms SAFE · AI writes the formula, you run it You describe the mess AI returns a rule you can read Excel applies it to a new column Raw column still there, both sides reconcilable Errors are loud: a bad rule breaks visibly, in every row at once, and you can undo it by deleting one column. RISKY · AI edits the values directly You paste 2,000 rows AI returns rows that look right You paste them over the original No rule, no raw copy, nothing to check against Errors are silent: one altered digit in row 1,317 is indistinguishable from correct data forever. The rule: let AI write the transformation, never let it be the transformation.
Both lanes end with a cleaned column. Only one of them leaves you able to prove the cleaning was correct.

Where AI genuinely earns its place

Writing the text formula you half-remember

This is the highest-value use and the lowest-risk one. Everyone knows TRIM exists; far fewer people remember that TRIM does not remove the non-breaking space (character 160) that arrives with every web copy-paste, which is why a cell that looks trimmed still fails a lookup.

=TRIM(A2)

=TRIM(SUBSTITUTE(SUBSTITUTE(A2, CHAR(160), " "), CHAR(9), " "))

Describe the symptom — "my VLOOKUP fails even though the two cells look identical" — and you get the second formula plus the reason. The formula is short enough to read, so you are not trusting the model, you are reviewing its work. That is the ideal shape of the interaction.

Splitting an inconsistently formatted column

A name column containing "SMITH, John", "john smith", "Dr. John Smith" and "Smith John" defeats Text to Columns because the delimiter and the order both vary. Describing the variants and asking for a formula gets you a nested conditional that handles each case explicitly. You will still find a fifth variant it did not cover — but you will find it in a visible #VALUE!, not in a silently mangled record.

Addresses behave the same way. Ask for the rule, apply it, then filter for rows where the output column is blank or errored and handle those by hand. That residue is usually small, and it is the honest part of the job.

Standardising labels against a list you supply

Turning "USA", "U.S.A.", "United States" and "us" into one value is safe when you supply the target list. You are asking the model to build a mapping table between things you have both seen, not to decide what the categories should be. Have it produce the lookup table, eyeball it, then apply it with a lookup formula so the mapping stays visible in the workbook.

The unsafe version of the same task is asking it to "tidy up the category column" with no list. Then it is inventing taxonomy, and it will happily fold two categories your business treats as distinct into one.

Generating and explaining a regex

Regex is the strongest case of all, because the output is pure rule and testable in seconds. Ask for a pattern that extracts an invoice number, paste it into a formula, and test it against ten known strings. Either it matches or it does not; there is no room for a plausible-but-wrong result to hide.

Describing what a column actually contains

Underrated. Paste a schema, or a sample of ten anonymised rows, and ask what the column probably represents, what formats appear in it and what would break a naive parse. This is analysis rather than transformation, so nothing is at stake if it is partly wrong, and it frequently surfaces a format variant you had not noticed.

Where it gets quietly dangerous

Every item here shares one property: the model cannot know the right answer, but nothing in its design lets it return "I do not know" for row 4,102 while returning a value for the rest.

Filling in blanks

An empty cell is information. It means the value was never captured, and downstream that distinction matters — AVERAGE skips blanks and includes zeros, and a filled-in guess becomes an observation the moment it is saved. Ask AI to fill gaps and you convert absence into fabricated presence, invisibly. If gaps must be filled, fill them with an explicit rule you chose (last known value, group median, a literal "Unknown") applied in a formula, so the choice is documented.

Inferring a value from another column

"Guess the country from the city" is the classic. It is right for Oslo and wrong for Springfield, Cambridge, San Jose and every other name that exists in several countries, and it is wrong without any signal that this row was harder than the last. Geographic, industry and currency inference all fail this way. Use a real reference table and a lookup that returns #N/A when the city is not in it, so unresolved rows stay visible.

Normalising identifiers

IDs, SKUs, account numbers and postcodes are exactly the strings you must not let a model touch, because they are arbitrary by design. A model that has seen millions of formatted identifiers has a strong prior about what one "should" look like, and a mangled-looking ID may be perfectly valid in your system. Reformatting is fine as a deterministic formula — pad to eight characters, strip hyphens — but only as a rule you specified.

Deduplicating near-matches

Deciding that "Acme Ltd" and "Acme Limited" are one customer is a business judgement with consequences: merged records, misattributed revenue, a deleted row nobody can recover. Exact duplicates are a solved problem you should handle with Excel's own tools — see how to remove duplicates in Excel — and near-duplicates should stay a human decision, with AI limited to building the normalised match key that groups the candidates.

Correcting values that look wrong

The most insidious one. Ask for cleaned data and you may get "corrections" you never requested: a date reformatted from your regional convention into another, a price with a decimal point moved because the original looked implausible, a spelling fixed on a proper noun that was correct. None of these are announced.

The task-by-task table

TaskSafe for AI?How to verify
Trim spaces, strip CHAR(160)Yes — write the formulaCompare LEN before and after; the difference is the characters removed
Split names or addressesYes — write the formulaFilter for blanks and errors in the output columns and fix that residue by hand
Fix case, e.g. PROPER or UPPERYes — write the formulaScan for acronyms and names like McDonald that case functions get wrong
Standardise labels to a list you supplyYes — build the mapping tableRead the mapping table; check every source value maps to something
Generate a regexYesTest against ten known-good and three known-bad strings before applying
Describe what a column containsYesNothing at stake — it is analysis, not transformation
Convert stored text to real numbers or datesYes — write the formulaCOUNT the result: it must equal COUNTA if every row converted
Fill in missing valuesNoUse an explicit rule you chose, or leave blank and count the blanks
Infer country, region or industryNoReference table plus a lookup that errors loudly on no match
Reformat or repair IDs and SKUsOnly as a rule you specifiedReconcile the distinct count of IDs before and after
Merge near-duplicate recordsNoAI builds the match key; a human approves each merge group
"Clean this up" on pasted valuesNoThere is no verification that scales — do not do this

The verification habits

These take about two minutes and they are what separates a cleaning step you can defend from one you merely hope is right.

1. Never overwrite the raw column

Insert a new column, put the formula there, and leave the original untouched until the whole job is finished and checked. Work on a copy of the file too. This single habit means every mistake below is recoverable rather than permanent.

2. Reconcile the row and value counts

Before and after should agree. COUNTA counts non-empty cells; COUNT counts only numeric ones. Run both on the source and the result:

=COUNTA(A2:A5000)          (source: cells with anything in them)
=COUNTA(D2:D5000)          (result: must match, or you lost values)

=COUNT(D2:D5000)           (result: cells Excel sees as numbers)
=COUNTA(D2:D5000)-COUNT(D2:D5000)   (how many did not convert)

If you were converting text to numbers, that last figure should be zero. If it is 63, then 63 rows are still text and will be skipped by every SUM and every pivot table downstream. This is the check that catches the largest class of silent failures.

3. Use LEN to see what actually changed

LEN is the cheapest audit in Excel. It tells you how much a transformation removed, which is a good proxy for whether it did what you intended:

=LEN(A2)-LEN(D2)

Expect small positive numbers when you are trimming. A row showing 40 means the transformation ate most of the value — worth opening. A column of zeros means your formula did nothing at all, which happens more often than people expect when the invisible character is not the one you targeted.

To count the affected rows in one cell before you commit:

=SUMPRODUCT(--(LEN(A2:A5000)<>LEN(TRIM(A2:A5000))))

If that returns 4 on a 5,000-row file, you have a four-row problem, not a whitespace epidemic, and you can fix those four by hand.

4. Check the distinct count, not just the total

After standardising labels, count unique values. Going from 40 spellings to 12 categories is the intended result. Going to 9 means the rule merged categories you needed kept apart, and that is far easier to spot now than in next quarter's report.

5. Read the twenty ugliest rows

Sort the result column ascending and descending and read the extremes at both ends. Rules break at the edges — the longest value, the shortest, the one with an apostrophe, the one already clean. Twenty rows of your own eyes catch things no count check will.

None of this is specific to AI, incidentally. It is the same discipline that catches the ordinary manual errors described in costly spreadsheet errors; AI simply raises the stakes by making it easy to transform 50,000 rows in one action.

A note on pasting company data into a chatbot

Before any of the above, there is a question of whether the data should leave the building. Consumer AI products may retain conversations, use them to improve models, or make them available for human review, and the settings that govern this differ between free and enterprise tiers and change over time. Customer records, employee data, salary tables, unreleased financials and anything covered by a client contract are usually not yours to paste, regardless of how careful the vendor is.

The workaround costs nothing and often produces a better answer. Describe the structure rather than the contents: "a column of UK postcodes where about a fifth have no space and some are lowercase". Or paste three rows with the values replaced by realistic fakes. You get the same formula, and it runs against the real file on your own machine. Since the safe pattern is to ask for a rule rather than for cleaned values, the privacy-preserving workflow and the accuracy-preserving workflow turn out to be the same workflow.

Stuck on a cleaning formula? Describe the mess in plain English in XLsheetAI and get the TRIM, SUBSTITUTE, TEXTSPLIT or regex you need, with an explanation of what it does — so you can check the rule before you run it on 50,000 rows.

Download on the App StoreGet it on Google Play

Bottom line

AI has made the annoying half of data cleaning much faster: remembering which function strips which character, writing the nested conditional that handles four name formats, producing a regex on demand. It has not made the careful half optional. The test before you delegate any step is a single question — is there exactly one correct output for a given input, and can it be expressed as a rule? If yes, ask for the rule and run it yourself. If no, the model does not know the answer either, and the difference between the two situations is that only one of them tells you so.

Frequently asked questions

Can AI clean messy Excel data for me?

It can write the cleaning step for you, and that is the safe way to use it. Describe the mess and ask for a formula, a Power Query step or a regex pattern, then run that rule yourself against your own data. What you should avoid is pasting the values in and asking for cleaned values back, because a language model produces plausible text rather than guaranteed-faithful text, and a single altered digit in the middle of ten thousand rows is invisible.

What data cleaning tasks should you never hand to AI?

Anything where the correct answer is a fact the model does not have. Filling in blank cells, inferring a country from a city name, repairing truncated customer IDs, deciding whether two similar-looking records are the same person, and correcting values that look wrong to a model but are actually right. These all require a source of truth outside the text, and when the model lacks one it will still produce an answer rather than an error.

How do I check that an AI-generated cleaning formula worked?

Keep the raw column, write the result into a new column, and reconcile. Compare COUNTA before and after to confirm no rows lost values, use COUNT to confirm numeric cells are still numeric, use LEN to see how many characters were actually removed, and sort the result column ascending and descending to surface the extreme cases. Then eyeball the twenty ugliest rows, because those are the ones any rule is most likely to mishandle.

Is it safe to paste company data into a general AI chatbot?

Treat it as publishing unless you know otherwise. Consumer chat products may retain conversations, use them for training, or expose them to human review, and customer records, salary tables and unreleased financials are usually covered by policies or contracts that prohibit that. The practical workaround costs nothing: describe the shape of the data instead of the data itself, or paste three anonymised sample rows, get the formula, and run it locally on the real file.

Can AI remove duplicates from a spreadsheet?

It can help you define what counts as a duplicate, which is the hard part, but the matching itself belongs in Excel. Exact duplicates are a solved problem with Remove Duplicates or UNIQUE. Near-duplicates such as Acme Ltd against Acme Limited are judgement calls with real consequences, so build a normalised match key with the formulas AI writes for you, review the groups it puts together, and delete only after a human has looked at the list.