Use Excel's AI to Write Formulas and Fix Model Errors

Tool:Microsoft Excel
AI Feature:Copilot
Time:10-15 minutes
Difficulty:Beginner

What This Does

Excel Copilot can write complex formulas from a plain-English description and troubleshoot broken formulas by explaining what went wrong. For financial analysts, this eliminates the 20–45 minutes typically spent looking up XLOOKUP syntax, debugging nested IF statements, or figuring out why your SUMIFS returns zero.

Before You Start

  • You have Microsoft 365 with a Copilot license
  • Your data is in an Excel table (formatted with Ctrl+T) or at minimum has clear column headers
  • You have a specific formula need or a broken formula to fix

Steps

1. Open your workbook and the Copilot pane

  1. Open the Excel file where you need the formula
  2. Click the Copilot button in the ribbon (sparkle icon, top right of Home tab)
  3. The Copilot sidebar opens

2. Describe the formula you need in plain English

Click in the Copilot text box and describe what you need. Be specific about your column layout.

For new formulas, use this pattern: "Write a formula that [what you want to calculate]. My data layout: Column A is [name], Column B is [name], Column C is [name]. I want the formula to [conditions or filters]."

Useful formula requests for financial analysts:

  • "Write a SUMIFS formula that totals column D (Actual) where column A equals '1000' and column B starts with '6'"
  • "Write an XLOOKUP that finds the budget amount for a cost center. The lookup value is in A2. The lookup array is in the Budget table column A. The return array is column C."
  • "Write a formula that calculates variance percentage: (Actual - Budget) / ABS(Budget). Handle the case where Budget is zero to avoid divide-by-zero errors."
  • "Write an IF formula that labels a variance as 'Favorable', 'Unfavorable', or 'On Plan' based on whether column E is positive, negative, or within 5% of zero."

3. Fix a broken formula

If you have a formula that's returning an error or wrong result:

  1. Click on the cell with the broken formula
  2. In the Copilot pane, type: "This formula is returning [error/wrong value]. Explain what's wrong and fix it: [paste the formula]"

Copilot will explain the issue in plain English and offer a corrected version.

What you should see: Copilot displays the working formula and explains each argument so you understand what to change in similar formulas.

4. Insert the formula

  1. Copilot shows the formula in the pane with an "Insert" button
  2. Click "Insert" to place it in the active cell, or copy-paste it manually
  3. Test it on a few rows before applying to the full column

Troubleshooting: If the formula inserts but returns wrong results, tell Copilot: "The formula is returning [X] but it should return [Y] for this row" and describe the data values. Copilot will diagnose the mismatch.

Real Example

Scenario: You're building a budget-vs-actual report. Your actuals table has cost center in column A, account code in column B, and actual spend in column D. Your budget table is on a different sheet named "Budget" with the same structure. You need to pull the corresponding budget amount for each row using a multi-condition lookup.

What you type: "Write an XLOOKUP that returns the budget amount from the Budget sheet. I need to match on two conditions: cost center (column A in both sheets) and account code (column B in both sheets). In my current sheet, the lookup values are in A2 and B2."

What you get:

Copy and paste this
=XLOOKUP(A2&B2, Budget!A:A&Budget!B:B, Budget!D:D, 0)

With an explanation: "This formula concatenates the cost center and account code values to create a unique key for matching, then looks for that combination in the Budget sheet and returns the corresponding budget amount in column D. If no match is found, it returns 0."

This formula would have taken 15–20 minutes to build correctly from documentation. Copilot produced it in 30 seconds.

Tips

  • If Copilot's formula works but is slow on large datasets, ask: "Is there a faster version of this formula for a 50,000-row dataset?"
  • Ask Copilot to add error handling: "Rewrite this formula to show 'No match' if the lookup fails instead of returning an error"
  • Use Copilot to convert VLOOKUP formulas to XLOOKUP: "Convert this VLOOKUP to XLOOKUP: [paste formula]". XLOOKUP handles left-side lookups and is significantly faster.

Tool interfaces change. If a button has moved, look for similar AI/magic/smart options in the same menu area.