Microsoft · KDD 2025 workshop

Fixing Excel formulas

At Microsoft, my co-authors and I tested whether a language model could fix a broken spreadsheet formula. We ran each repair in the sheet to see if it gave the right answer.

Try a price lookup

This example from our paper looks up the price of a fruit. Mango is missing from the list.

Item to find Mango

Original formula
#N/A
Repaired formula
Not found

Prices in the published worksheet. Apple 1.2, Banana 0.5, Cherry 2, Date 3, Fig 2.5 and Grape 2.8.
The price list in Figure 4
See the two formulas

The original formula asks for the price in column B. The repair first checks whether the fruit appears in column A.

Original=VLOOKUP(A10,A2:B7,2,FALSE)

Repaired=IF(COUNTIF(A2:A7,A10)>0,VLOOKUP(A10,A2:B7,2,FALSE),"Not found")

How often did the repair work?

GPT-4.1 returned the expected result on 80% of our generated cases and 41% of the original forum examples. The other three models also did worse on the forum cases.

All four models score lower on the forum cases. Exact matches fall from 80% to 41% for GPT-4.1, 73% to 35% for GPT-4o, 58% to 24% for Phi-3, and 51% to 19% for Mistral.
Exact execution match across the two datasets · Table 5
See all scores for the four models

We checked three things. Was the formula valid? Did it run? Did the result match the expected value?

FoRepBench results · percentage of cases
Model Dataset Syntax Runs Exact match
GPT-4.1 Generated 100% 96% 80%
GPT-4.1 Forum seed 98% 65% 41%
GPT-4o Generated 100% 93% 73%
GPT-4o Forum seed 96% 63% 35%
Phi-3 Generated 81% 77% 58%
Phi-3 Forum seed 73% 41% 24%
Mistral Generated 78% 76% 51%
Mistral Forum seed 67% 37% 19%

Where the cases came from

We started with 59 real examples from Excel forums. Each needed the person’s question, the sheet and a repair we could run. We generated variations and kept 618 that passed our checks.

A forum post from Figure 1 with the user’s question, formula and worksheet marked for extraction.
We marked the question, formula and worksheet in this forum post. See all of Figure 1.

Worksheet images adapted from Figures 1 and 4 of Benchmark Dataset Generation and Evaluation for Excel Formula Repair with LLMs, Singha et al. CC BY 4.0.

Read the paper on arXiv