Run a Python analysis in Excel with Copilot's Advanced Analysis
Put the data in a Table in a cloud-saved workbook, start Advanced Analysis in Copilot, let it write Python cells, and read each one before you reuse the code.

Tools used
- Copilot in ExcelWrites and fixes the Python cells
- Python in ExcelRuns the analysis inside the workbook
- Excel (Microsoft 365)Holds the source Table
Step navigator
Python cells in your workbook that you have read, re-run and checked against the source table.
Excel users who want forecasts or charts Excel cannot do natively, without learning Python first.
Before you start
People on r/excel are mostly unimpressed by Copilot for everyday formulas, but several point to its ability to write Python in Excel as the useful part. One user explains how they start it and what they do with the code afterwards; a data-science blogger documents the setup.
Step-by-step instructions
Put the data in a Table and save the workbook to the cloud
Copilot needs the data in an Excel Table and the file on OneDrive or SharePoint. One user's complaint: "the data needs to be in a table. It will also only work if you store your file in oneDrive or sharepoint." Turn on AutoSave, choose a cloud location, then reopen the file from there.

Click in the table and start Advanced Analysis
Click inside the table, open Copilot, ask it to start advanced analysis, then select Start. One r/excel user: "First prompt is 'Python'. They should show you a button for 'Start Advanced Analysis'." Copilot adds a new sheet for its Python cells.
Please start advanced analysis.
Ask for one analysis at a time
Ask for one specific result, such as a forecast or a chart. Microsoft's example prompt is "Forecast sales for the next 4 quarters", and Copilot keeps the context of earlier asks so you can build step by step. When the Python errors, the r/excel user says Copilot will "even rewrite it if the first Python generates an error."
The Sales table has one row per month. Create a DataFrame indexed by month and forecast the next 4 quarters. Show the code and a chart.
Why this works
One ask at a time keeps each cell easy to check.
Expect different results on different runs, and read the code
The blogger who documented this notes that Copilot sometimes only loads the table and sometimes runs extra analyses: "There is a certain level of randomness." Open each Python cell and read what it computes before trusting the output.
Why this works
Knowing what the code does is the only way to catch a wrong analysis.
Copy the working code into your real workbook
Once a cell does what you want, reuse it. The r/excel user: "Once Copilot writes some useful Python, I will copy it back to my real workbooks (with AutoSave off) for further use."
End of guide · Reviewed Oct 26, 2026
Pro tips2
- Keep a scratch copy for Copilot experiments and copy only finished code into your real file.
- Ask Copilot to explain each line of the Python it wrote; users treat this as a way to learn Python.
Common mistakes3
- Starting Advanced Analysis on a range that is not a Table.
- Accepting a forecast without reading which columns the code used.
- Experimenting on the real file with AutoSave on.


