Use AIUnderstand AIBuild with AI
Use AI·How-to·· 4 min read

Use AI to Write Spreadsheet Formulas You Don't Know How to Write

Describe what you want in plain words, get a working formula, learn what it does, and test it before you trust it.

You know what you want from your spreadsheet. Add up only the rows for one customer. Flag invoices that are overdue. Pull a price from another sheet. What you don’t know is the formula that does it.

AI assistants are good at turning a plain description into a formula. They can also explain a formula someone else wrote and help you find out why yours shows an error. The catch is that a formula can look right and still give a wrong answer. This guide shows how to ask well and how to test the result.

Step 1: Describe your sheet, not just your goal

The AI can’t see your spreadsheet. If you say “add up the sales,” it has to guess where the sales are. Tell it which columns hold what, which row your data starts on, and which program you use. Excel and Google Sheets share most formulas, but not all of them.

I'm using [Excel / Google Sheets]. Please write a formula for me.
My data starts in row 2. The columns are:
- A: Date
- B: Customer name
- C: Product
- D: Amount (a number)
- E: Paid? (the word "Yes" or "No")
What I want: [e.g. the total amount for customer "Smith" where Paid? is "No"]
Where the answer should go: [e.g. cell H2]
Give me the formula, then explain each part in plain English. Then give me one small example with made-up numbers so I can check it.

The made-up example is the most useful part. You can type those few rows into a blank sheet and see whether the formula behaves.

Step 2: Put the answer in a safe place

Paste the formula into a spare cell or a copy of the sheet, not on top of your real data. If something goes wrong, you haven’t lost anything.

Step 3: Test it with answers you already know

This is the step people skip. Before you trust a formula, give it a case where you can work out the right answer by hand.

  • Pick a small group of rows and add them up yourself with a calculator.
  • Compare your number with the formula’s number.
  • Try an edge case: a customer with no rows, a blank cell, a name with an extra space, or a date written two different ways.

If the numbers differ, tell the AI exactly what you see.

The formula you gave me returns [what I got], but when I add the rows by hand I get [what I expected]. Here are the rows I checked:
[paste 3–5 sample rows, with any private details replaced by placeholders]
What is going wrong? Check whether my data might have extra spaces, numbers stored as text, or dates stored as text. Give me a corrected formula and tell me what you changed.

Step 4: Ask it to explain formulas you already have

Sometimes you inherit a spreadsheet and nobody remembers how it works. Copy one formula at a time and ask what it does.

Explain this spreadsheet formula to me as if I've never written one. Go through it piece by piece, then say in one sentence what it does overall. Tell me what would make it break or give a wrong answer.
Formula: [paste formula]
Program: [Excel / Google Sheets]

You can also ask for a simpler version if a formula is long and tangled, so that you or a coworker can read it later.

Step 5: Fix error messages

Errors like #N/A, #REF!, #VALUE! and #DIV/0! look scary, but each one points to a kind of problem. Paste the formula and the error and ask what the error means in this case.

My formula shows the error [error text]. The formula is: [formula].
Here is what the cells it refers to contain: [describe, e.g. "A2 is a date, B2 is blank, Sheet2 column A holds product names"].
Explain in plain English what is causing the error and how to fix it.

Other things to ask for

  • Several approaches. “Give me two different ways to do this and tell me the trade-offs.”
  • Cleaning data. “Write a formula that removes extra spaces from names in column B.” or “Split full names in column B into first and last names.”
  • Learning. “After you give me the formula, give me three practice questions that use the same idea.”

Check the result

AI formulas have common failure points:

  • Wrong program. Some functions exist in one program and not the other, or are named differently. If you get a “name” error, say which program you use and ask again.
  • Wrong columns. If you changed or inserted columns after describing them, the cell references may no longer match. Read the formula and check that each column letter points where you expect.
  • Ranges that stop too early. A formula that covers rows 2 to 100 will miss row 101. Ask how to make it cover new rows as you add them.
  • Text that looks like numbers. If a column of numbers is stored as text, totals can come out as zero or too small. Ask the AI how to check for that.
  • Confident explanations that are wrong. The AI can describe what a formula does and be mistaken. Your hand-worked test is the real proof.
  • Missing cases. A formula may work on your five test rows and fail on the real file. Test blanks, duplicates and unusual entries.

For anything important, such as invoices, payroll, grades or taxes, double-check totals independently, and ask a colleague or professional to review the setup before you rely on it.

Protect private data

Spreadsheets often hold names, addresses, account numbers, salaries or customer details. You almost never need to share those to get a formula. Describe the columns in words, as in the prompts above, or paste a few sample rows with invented values. If you must paste real rows, remove or replace anything personal first. If the file belongs to your employer, check their rules on AI tools before pasting anything from it.

Related