You know what you want from a spreadsheet: add expenses for one category, calculate a row total, or flag an overdue item. The difficult part is translating that request into a formula with the right function, references, and conditions.
AI can help draft the formula and explain how it works. However, a formula that returns a number is not necessarily correct. It may use the wrong column, skip part of the data, or produce an unexpected result when copied to another row.
This guide explains how to use AI to write spreadsheet formulas, test them on small examples, and check the details before applying them to a working sheet.
![]() |
| Describe your data clearly, understand the suggested formula, and verify its results with small test cases. |
Start with the Calculation, Not the Function Name
Describe the result you need in plain language. You do not have to know whether the solution requires SUMIF, SUMIFS, or another function before asking for help.
For example, “add the amounts in column C when the category in column B is Travel” is more precise than “write an expense formula.”
Explain what should happen in unusual cases too. If a category is missing, should the result be zero, blank, or a warning? Those choices affect the solution.
Tell the Assistant Which Spreadsheet App You Use
Identify the application and, when relevant, its version. A formula designed for a newer Excel feature may not work in an older installation. Functions and behavior can also differ between Excel and Google Sheets.
Mention your formula language and regional settings if they affect your sheet. The examples in this article use English function names and commas between function arguments.
Google documents how spreadsheet locale and function-language settings work in its guide to location and calculation settings in Google Sheets. If an example does not parse in your file, inspect the settings and a working formula before changing the calculation itself.
Provide a Clear Map of Your Data
Describe the columns, header row, and data range. A small sample is usually more useful than a vague description of a large workbook.
Application: Microsoft Excel Headers: Row 1 A: Date B: Category C: Amount Data rows: 2 through 5 E2: Category to total F2: Cell where the result should appear Goal: Add amounts in C2:C5 when the category in B2:B5 matches E2.
Use fictional or sanitized records when asking an external tool for help. Keep the structure and data types representative without sharing unnecessary private information.
For more help describing a task precisely, see our guide to writing better AI prompts with clear context and constraints.
A Worked Example: Total Expenses by Category
Suppose you enter the following fictional data in cells A1:C5. The row numbers in the first column identify spreadsheet positions; they are not an additional data column.
| Row | A — Date | B — Category | C — Amount |
|---|---|---|---|
| 2 | October 1 | Travel | 25 |
| 3 | October 2 | Software | 15 |
| 4 | October 3 | Travel | 40 |
| 5 | October 4 | Supplies | 10 |
Enter Travel in E2. A formula for F2 is:
=SUMIF($B$2:$B$5,E2,$C$2:$C$5)
The expected result is 65, because the two Travel amounts are 25 and 40.
The formula has three parts:
- $B$2:$B$5: The category cells checked against the condition.
- E2: The cell containing the category to match.
- $C$2:$C$5: The corresponding amounts to add.
Microsoft's SUMIF function documentation explains the function's arguments and examples. Check the documentation when you need to understand a condition or limitation.
Ask for an Explanation and Test Cases
A useful response should help you understand the formula rather than leave you with something you can only copy.
Write a formula for the spreadsheet described below. Return: 1. The formula. 2. Where to enter it. 3. A plain-language explanation of each part. 4. Assumptions about the data. 5. Small test cases with expected results. 6. Any application or version requirements. Use the exact columns and ranges I provide. Do not assume missing columns exist. Ask if a missing detail changes the calculation. SPREADSHEET: [Describe the application, columns, ranges, and desired result.]
Inspect the proposed test results independently. An assistant can make the same reasoning error in both its formula and its explanation.
Test the Example Before Expanding the Range
Use a copy of your sheet or a small test area. For the expense example, change the criterion in E2 and compare the results with manual addition.
| Value in E2 | Expected result | Reason |
|---|---|---|
| Travel | 65 | 25 + 40 |
| Software | 15 | One matching row |
| Supplies | 10 | One matching row |
| Training | 0 | No matching category in the sample |
Then test a controlled change. If the Travel amount in C2 changes from 25 to 30, the Travel total should become 70.
These checks verify the stated example. They do not establish that every possible input in a larger workbook is handled correctly.
Understand What Happens When You Copy the Formula
In the example formula, the dollar signs keep the source ranges fixed when you copy the formula. The reference E2 remains relative.
If you copy F2 down to F3, the formula should become:
=SUMIF($B$2:$B$5,E3,$C$2:$C$5)
That is useful when E3 contains another category. However, it would be wrong if your intention was to keep checking E2 in every copied formula.
Tell the assistant how you plan to copy the formula. References that work in one cell may not behave as intended across a full table.
Check Whether New Rows Are Included
The example uses a fixed range ending at row 5. Adding another expense in row 6 does not make that row part of the specified range.
Before using the formula regularly, decide how the data range should grow. Depending on your application and workbook design, you might extend the range or use a supported table-based approach.
Do not accept a solution described as automatically expanding without testing it. Add a sample row and confirm that the result changes as expected.
Look for Data Problems Before Rewriting the Formula
An unexpected result may come from the data rather than the function. Inspect a few representative cells.
- Numbers stored as text: An amount that looks numeric may not be treated as a number.
- Inconsistent category labels: Extra spaces or different wording can affect matching.
- Wrong ranges: The formula may inspect categories and amounts from different rows.
- Unexpected duplicates: A repeated record may be included more than once.
- Blank or error cells: Decide how these should be handled rather than hiding them automatically.
Formatting a cell to look like a number is not the same as verifying its stored value. Investigate the input before adding layers of error handling.
Do Not Hide Errors Just to Make the Sheet Look Clean
A wrapper that replaces every error with zero or a blank can conceal a broken reference or unsupported function.
First understand the cause. Then decide which expected situations should receive a fallback result.
This formula returns an error in the sample below. Explain the likely cause using the supplied data. Do not add error suppression until the underlying issue is identified.
When asking for help, include the exact formula, the displayed error, your application, and a small relevant sample.
Keep a Record of the Formula's Purpose
For a sheet you will reuse, record what the formula calculates, which inputs it expects, and how you tested it. A short note can prevent future edits from changing its meaning accidentally.
If AI proposes a revision, compare the old and new logic. Check whether it changes range boundaries, matching conditions, or treatment of missing data.
Our guide to comparing versions and checking important changes with AI explains a similar review principle: distinguish the observed edit from assumptions about its effect.
A Final Review Before Using the Formula
- Confirm the application and supported functions.
- Check every source range and criterion.
- Calculate at least one expected result independently.
- Test matching, nonmatching, and relevant unusual inputs.
- Copy the formula in the intended direction and inspect the references.
- Add a sample row if the sheet will grow.
- Keep the original data and a way to undo the change.
For a broader verification process, read our guide to checking AI answers against evidence and independent calculations.
Frequently Asked Questions
Can AI write formulas for Excel and Google Sheets?
It can propose formulas for both, but you need to specify the application and check compatibility. Similar-looking functions do not guarantee identical behavior in every situation.
Is a formula correct if it returns a number?
No. It may calculate the wrong range or apply the wrong condition. Compare the result with a known example.
Should I upload the entire workbook?
Not necessarily. A small, sanitized sample with the correct structure may be sufficient. Share only material you are permitted to provide.
Why does the formula fail when I paste it?
Possible causes include unsupported functions, regional syntax differences, copied formatting, or references that do not match your sheet. Check the exact error before changing the formula.
Can AI guarantee that a spreadsheet is error-free?
No. Generated formulas and explanations need review. Important calculations require checks appropriate to how the workbook will be used.
Use AI to Understand the Calculation
Describe the result, provide a clear data map, and ask for an explanation alongside the formula. Test small examples before applying the solution to a larger sheet.
The useful outcome is a calculation you can explain and verify, not just a formula that appears to work once.

