AI & Python function

COPILOT function

Sends a prompt, plus optional cell data as context, to Copilot's AI model and returns its generated answer into the grid. Results can vary.

Available in Microsoft 365 only. Rolling out gradually to users with a Microsoft 365 Copilot licence, starting with Insider/Beta channels; check your Excel version, as availability varies by platform and region.

Microsoft 365 onlyNot in Google Sheets

Syntax

COPILOT(prompt_part1, [context1], [prompt_part2], [context2], ...)
ArgumentWhat it means
prompt_part1RequiredText that tells the AI what to do, e.g. "Classify this comment as Positive, Negative or Neutral".
context1OptionalA cell or range whose contents are given to the AI along with the prompt.
prompt_part2, context2, ...OptionalFurther pieces of instruction and context, combined in order into one prompt.

Returns: AI-generated text (or a spilled array of results when the task produces several answers).

How COPILOT works

COPILOT brings a large language model into an ordinary formula. You write an instruction in plain language, point it at the cells it should work on, and the answer comes back into the cell like any other result. It is aimed at tasks that are easy to describe but hard to express as a formula: sorting free-text customer comments into categories, summarising feedback, extracting themes, drafting short product descriptions or tagging support tickets.

The arguments alternate between instruction text and context: =COPILOT("Summarise", B2:B20, "in one sentence for a manager"). Because the context is a cell reference, the formula recalculates when that data changes, and it can be filled down or combined with other functions such as IF and FILTER.

Treat the output as a draft, not a fact. Language models can produce different wording for the same input, can misclassify borderline cases, and can state wrong things confidently. Microsoft advises against using COPILOT for numerical calculations, for anything that must be reproducible, or for high-stakes decisions — use normal Excel functions for arithmetic. The function also does not look things up on the web or in your company's files; it only sees the prompt and the cells you pass in. All results on this page are illustrative: your output may differ.

Examples

1Classify customer feedback

C2fx=COPILOT("Classify this comment as Positive, Negative or Neutral. Reply with one word.", B2)
ABC
1TicketComment
2T-301Delivery was fast and the support team was really helpful.Positive
3T-302Second time the invoice was wrong. Very frustrating.
4T-303Can I change my billing address online?

Result: Positive

Illustrative result. The model reads the comment in B2 and answers with one of the three labels. Asking for a fixed list and "one word" makes the output consistent enough to count with COUNTIF; filled down, T-302 would likely be Negative and T-303 Neutral.

2Draft a short product description

C2fx=COPILOT("Write a product description of at most 20 words for", A2, "using these features:", B2)
ABC
1ProductKey features
2Ergo desk chairadjustable lumbar support, breathable mesh, 5-year warrantyStay comfortable all day with adjustable lumbar support, breathable mesh and a reassuring 5-year warranty.

Result: Stay comfortable all day with adjustable lumbar support, breathable mesh and a reassuring 5-year warranty.

Illustrative result — the wording will differ each time you generate it. The prompt is assembled from four parts: instruction, product name, a second instruction and the feature list. Review every draft before using it in a catalogue.

3Label several comments at once

C2fx=COPILOT("Give the main topic of each comment in two words or fewer", B2:B4)
ABC
1TicketComment
2T-301Delivery was fast and the support team was really helpful.Delivery service
3T-302Second time the invoice was wrong. Very frustrating.Invoice errors
4T-303Can I change my billing address online?Billing address

Illustrative result. Passing a range lets the model return one answer per row, which spills down. Topic labels like these are a quick way to group a long feedback list before reading it in detail.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

Common errors and how to fix them

ErrorWhy it happensFix
Error or no resultNo Microsoft 365 Copilot licence, no internet connection, or a temporary usage limit has been reached.Check your licence and connection; if you hit a limit, wait and recalculate later, and avoid filling the formula down thousands of rows at once.
#NAME?Your Excel build does not have the COPILOT function yet.Update Excel or check whether the feature has reached your update channel.

Tips

  • Be specific: name the allowed answers, the length and the format ("one word", "under 20 words", "a number from 1 to 5").
  • Once you are happy with the AI-generated labels, consider copying them and using Paste Special > Values so the results don't change on later recalculation.
  • Do not send confidential data you are not allowed to share with your organisation's AI tools; COPILOT passes the referenced cells to the model.

Questions

Can I use COPILOT for calculations?

It is not designed for that. AI answers are not guaranteed to be numerically correct or repeatable; use Excel functions such as SUM or AVERAGE for numbers.

Does COPILOT search the internet or my files?

No. It works only with the prompt text and the cells you reference in the formula, plus the model's general knowledge.

Google Sheets

Not available; Google Sheets has its own Gemini-powered AI function in some Google Workspace plans.