Can AI write spreadsheet formulas for me?
Yes, and it's one of the best uses of AI. Describe your columns and what you want, and it writes the exact formula for Excel or Google Sheets and explains each part.
01Why bot
- Formulas are short, precise and well documented, which suits AI.
- It explains the formula so you can fix it later.
- You can test it right away on your own sample rows.
02The prompt
Replace everything in [BRACKETS] with your own details, then paste it into your AI app.
You are a spreadsheet formula expert. Tool: [EXCEL OR GOOGLE SHEETS] My columns and a few sample rows: [PASTE] What I want: [GOAL] Your task: write the formula. Rules: - MUST use my actual column letters and ranges. - MUST show what the formula returns on my sample rows. - NEVER use functions my tool doesn't support. - If anything is missing, ask me up to 3 short questions first. Give me: the formula, which cell to put it in, and a one-line explanation of each part.
03Steps
- Copy a few sample rows, with fake data if the real data is private.
- Paste them into the prompt.
- Test the formula on your sample before filling it down.
04What can go wrong
- Check the result on a row you can work out by hand.
- Don't paste customer or financial data you're not allowed to share.
05What to use
06Our test runs
2 runs, each with a different made-up sample. 2 of 2 passed every check.
The made-up sample:
[EXCEL OR GOOGLE SHEETS]Google Sheets[PASTE]A: Date | B: Sales | C: Region | D: Units Sold Row2: 2024-01-01 | 1500 | North | 30 Row3: 2024-01-02 | 2300 | South | 45 Row4: 2024-01-03 | 1800 | East | 40 Row5: 2024-01-04 | 2100 | North | 35[GOAL]Create a column (E) that shows the cumulative total of Sales (column B) from the first row down to each row.
- Use actual column letters and ranges
- Show formula returns on sample rows
- Never use unsupported functions
- Provide formula, cell, and one-line explanation
- Didn't make up details we never gave it
What came back (excerpt):
ormula: Formula: =SUM(B$2:B2) Cell: E2 Here's a breakdown of the formula: - `B$2` refers to the first cell in the range that we want to sum, with the `$` sign making the row number absolute so it doesn't change when we copy the formula down.
Read the full answer
To calculate the cumulative total of Sales, you can use the following formula: Formula: =SUM(B$2:B2) Cell: E2 Here's a breakdown of the formula: - `B$2` refers to the first cell in the range that we want to sum, with the `$` sign making the row number absolute so it doesn't change when we copy the formula down. - `:B2` specifies the range from the first cell to the current cell, allowing the formula to adjust as we copy it down. - `SUM` calculates the sum of the values in the specified range. When you enter this formula in cell E2 and copy it down, it will return the following values for your sample rows: - E2: =SUM(B$2:B2) returns 1500 - E3: =SUM(B$2:B3) returns 3800 - E4: =SUM(B$2:B4) returns 5600 - E5: =SUM(B$2:B5) returns 7700 To apply this formula to the rest of the cells in column E, simply copy the formula down from cell E2.
All required elements are satisfied.
The made-up sample (a messier one):
[EXCEL OR GOOGLE SHEETS]Google Sheets[PASTE]A1:D6 Date Salesperson Region Sale Amount 2024-01-01 Alice North 450 2024-01-02 Bob South 720 2024-01-03 Alice North 310 2024-01-04 Charlie East 150 2024-01-05 Alice West 820[GOAL]Add a formula in column E that gives the running total of sales for the same region, but only include rows where the Sale Amount is greater than $300.
- Use actual column letters and ranges
- Show formula returns on sample rows
- Never use unsupported functions
- Provide formula, cell, one-line explanation
- Didn't make up details we never gave it
What came back (excerpt):
To achieve the desired result, I'll provide the formula and explanation.
Read the full answer
To achieve the desired result, I'll provide the formula and explanation. Put the formula in cell E2: `=SUMIFS($D$2:$D2, $C$2:$C2, $C2, $D$2:$D2, ">300")` Here's a breakdown of the formula: - `SUMIFS`: sums up the values in the specified range that meet the given conditions. - `$D$2:$D2`: the range of cells to sum up, which is the Sale Amount column up to the current row. - `$C$2:$C2`: the range of cells to check for the region condition. - `$C2`: the value to match for the region condition, which is the region of the current row. - `$D$2:$D2`: the range of cells to check for the Sale Amount condition. - `">300"`: the value to match for the Sale Amount condition, which is any value greater than 300. To apply this formula to the rest of the cells in column E, you can drag the formula down or use an array formula. Here's what the formula returns for your sample rows: - E2: 450 (since 450 is greater than 300 and it's the first row for the North region) - E3: 720 (since 720 is greater than 300 and it's the first row for the South region) - E4: 450 + 310 = 760 (since 310 is greater than 300 and it's the second row for the North region) - E5: 150 (not included since 150 is not greater than 300) - E6: 820 (since 820 is greater than 300 and it's the first row for the West region) However, the above formula doesn't quite meet the requirements as it doesn't correctly calculate the running total for each region. A more accurate formula would be: `=SUMIFS($D:$D, $C:$C, $C2, $D:$D, ">300", $A:$A, "<="&$A2)` This formula should be put in cell E2. Here's a breakdown of the formula: - `SUMIFS`: sums up the values in the specified range that meet the given conditions. - `$D:$D`: the range of cells to sum up, which is the entire Sale Amount column. - `$C:$C`: the range of cells to check for the region condition. - `$C2`: the value to match for the region condition, which is the region of the current row. - `$D:$D`: the range of cells to check for the Sale Amount condition. - `">300"`: the value to match for the Sale Amount condition, which is any value greater than 300. - `$A:$A`: the range of cells to check for the date condition. - `"<= "&$A2`: the value to match for the date condition, which is any date less than or equal to the date of the current row. Here's what the formula returns for your sample rows: - E2: 450 (since 450 is greater than 300 and it's the first row for the North region) - E3: 720 (since 720 is greater than 300 and it's the first row for the South region) - E4: 450 + 310 = 760 (since 310 is greater than 300 and it's the second row for the North region) - E5: 0 (since 150 is not greater than 300) - E6: 820 (since 820 is greater than 300 and it's the first row for the West region) To apply this formula to the rest of the cells in column E, you can drag the formula down.
Watch for the extra, unnecessary first formula that may cause confusion.
How each run works: we fill the prompt with a made-up sample, run it once in Llama 3.3 70B, and GPT-OSS 120B grades the answer against the prompt's own rules. Word limits are counted by code, and every quote flagged as made up is checked against the full answer. Your results can differ. How we test.