How to Use ChatGPT to Write Excel Formulas
To use ChatGPT to write an Excel formula, describe the result you want in plain English — including your column layout and one example — and ChatGPT returns a formula you paste into your sheet and verify. For working on an actual file, upload it (on a paid plan) and ChatGPT can read, clean, chart, and even return the spreadsheet for you. The one rule that never changes: test what it gives you before you trust it.
This guide shows the exact prompting workflow, real examples, how to debug, how the file-upload feature works, and the limits worth knowing.
The basic workflow
- Describe the task with context. Tell ChatGPT what your data looks like — which columns hold what, a sample row, and the exact result you want. “I have names in column A and amounts in column B. Write a formula to total only the amounts over 100.”
- Copy the formula it returns.
- Paste it into Excel and adjust the cell references to match your real ranges.
- Test it on a few rows where you know the answer.
- Iterate if needed. “That returns
#N/Afor blanks — make it return 0 instead.” ChatGPT refines it.
The single biggest quality lever is step 1. ChatGPT can’t see your sheet, so the more precisely you describe the layout, the better the formula.
A prompt template that works
I’m using Excel [version, e.g. Microsoft 365, on Windows]. My data: column A = customer, column B = order date, column C = amount. I want [the exact result]. Write a single formula I can put in cell E2 and fill down, and briefly explain it.
Naming the version matters because newer functions like XLOOKUP and dynamic arrays aren’t available in older Excel. Giving the target cell helps ChatGPT get the relative and absolute references right.
Real examples
- “Sum column C where column B is ‘West’.” →
=SUMIF(B:B,"West",C:C) - “Look up the price in the Products sheet by the SKU in A2.” →
=XLOOKUP(A2,Products!A:A,Products!C:C)(or VLOOKUP on older Excel) - “Count how many unique customers are in column A.” →
=COUNTA(UNIQUE(A2:A1000)) - “Flag rows where the amount is over budget in column D.” →
=IF(C2>D2,"Over","OK") - “Days between the date in B2 and today.” →
=TODAY()-B2
If any of these functions are new to you, the complete guide to Excel formulas and the essential functions for office workers explain how they work, so you can confirm ChatGPT used the right one.
Explaining and debugging existing formulas
ChatGPT is just as useful in reverse. Paste a formula you inherited and ask “What does this do, step by step?” Or paste one that’s broken — “Why is this returning #REF! and how do I fix it?” — and it will usually spot the cause. Our error code guide and common mistakes article are good companions when you’re untangling someone else’s workbook.
Writing VBA macros and scripts
When you need automation, ChatGPT can write VBA macros and Office Scripts from a description — “Write a macro that saves each sheet as its own PDF.” Paste it into the VBA editor and run it. New to macros? Start with our VBA for beginners guide. Always read and test generated code on a copy first; a macro is powerful and AI-written code can contain mistakes.
Uploading a spreadsheet for analysis
Beyond formulas, ChatGPT can work on an actual file. Its data-analysis feature reads .xlsx, .xls, and .csv files in a secure Python environment, so you can ask it to clean messy data, build a pivot summary, create charts, merge datasets, or hand back a processed file — without copy-pasting.
Access differs by plan: free accounts get a small number of file uploads per day with limited analysis, while ChatGPT Plus ($20/month) unlocks the full data-analysis capability. This is the most hands-off way to analyze a spreadsheet, but it works on a copy you upload — it isn’t editing the file live on your computer.
Limits worth knowing
- ChatGPT can’t see your live sheet. It only knows what you describe or upload, so wrong context means wrong references.
- It can invent functions or wrong syntax, especially for your specific Excel version or regional settings. Always test.
- It doesn’t know your real numbers unless you share them — verify totals, particularly anything financial where a rounding error hides easily.
- Privacy. Don’t upload sensitive, personal, or regulated data without approval, and be careful with files from unknown sources.
ChatGPT vs. Copilot vs. Claude for formulas
All three can write formulas. ChatGPT is the most accessible and flexible (no add-in required, strong file analysis). Microsoft Copilot generates formulas natively inside the Excel grid but needs a Microsoft 365 Copilot license. The Claude add-in shines at explaining and debugging large models — see how to use Claude with Excel, or the overview in how to use AI in Excel.
Tips for better formulas
- Always state your Excel version and platform.
- Give a sample of your data and name the target cell.
- Ask for an explanation alongside the formula so you learn, not just paste.
- Build a formula up in steps for complex logic rather than asking for one giant nested formula.
- Verify against a row you can check by hand.
Prefer a workbook that’s already built and tested? Our ready-made Excel templates come with the formulas done for you.
Frequently Asked Questions
Can ChatGPT write Excel formulas for free?
Yes. The free tier of ChatGPT can write formulas from a description at no cost — you copy the formula and paste it into Excel. Paid plans add the full file-upload data-analysis feature, but you don’t need to pay just to generate formulas.
Can ChatGPT read my Excel file?
Yes, with its data-analysis feature it can read .xlsx, .xls, and .csv files you upload and then clean, summarize, chart, or transform them. Free accounts get limited uploads per day; ChatGPT Plus unlocks full analysis. It works on the uploaded copy, not your live local file.
Why does the formula ChatGPT gave me not work?
Usually one of three reasons: the cell references don’t match your actual layout, the function isn’t available in your Excel version (e.g. XLOOKUP on Excel 2019), or your regional settings use semicolons instead of commas as argument separators. Tell ChatGPT your version and exact layout and ask it to fix it.
Is it safe to paste my data into ChatGPT?
Use caution. Avoid sharing sensitive, personal, or regulated data without your organization’s approval, and review OpenAI’s data-handling settings. For formula help you rarely need to share real data at all — describing the structure is usually enough.
Can ChatGPT write VBA macros too?
Yes. Describe what you want and it will write a VBA macro or an Office Script you paste into Excel. Read and test any generated code on a copy before running it — see our VBA for beginners guide.
Should I use ChatGPT or Microsoft Copilot for Excel?
If you want a free, flexible option and don’t mind copy-pasting, ChatGPT is excellent. If you already have a Microsoft 365 Copilot license and want formulas generated inside the grid, Copilot is smoother. Many people use both — more in how to use AI in Excel.