google sheets

Build Your Own ChatGPT Function Inside Excel with an API Key

You're right that Google Sheets has its `=AI` function and Microsoft offers `=Copilot`, but OpenAI hasn't shipped a native `=CHATGPT()` formula for Excel.

4 min readMicrosoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

The question lands in our inbox with the quiet desperation of someone who has already hit the wall. You want a ChatGPT function that lives inside an Excel cell, fills down like any other formula, and works with your company's OpenAI setup. You're not asking for a sidebar panel that floats around like a helpful ghost. You want the data to move, transform, and return values in place. That's the right instinct. And the fact that you're asking how to build it with VBA and an API key tells us you're already thinking like a builder, not a bystander.

Here's the honest take: there is no native `=CHATGPT()` function in Excel today, and Microsoft's `=COPILOT` is not the same animal. Copilot is an assistant that lives in the ribbon, not a formula you can drag down a column. Google Sheets has experimented with AI helper functions, but your company chose OpenAI, and that choice is defensible. The real opportunity is that you can absolutely create a custom function using VBA and the OpenAI API. You'll write a UDF (user-defined function) that calls the API endpoint, passes the cell's content as a prompt, and returns the response. The key is handling the fact that VBA is synchronous while API calls are asynchronous by nature. You'll need to make the function wait for the response, which means using `WorksheetFunction.Run` or a separate HTTP request with a timeout. It's not plug-and-play, but it's far from impossible.

What matters more than the technical trick is the philosophy behind it. You're not just asking for a formula; you're asking for a workflow where AI becomes a first-class citizen in your spreadsheet, not a sidekick you summon in a panel. That distinction is worth fighting for. When you embed intelligence directly into cells, you enable patterns like batch classification, dynamic summarization, or even sentiment scoring across rows. You can see the results alongside the data, audit them, and refine your prompts. That's a form of verifying your AI’s understanding that a chat interface rarely offers. At the same time, this approach raises the stakes around data security. When you send cell contents to an external API, you're moving data outside your environment. That's a real concern, and it mirrors the data security worries that surface when AI agents operate without strict boundaries. Before you write a single line of VBA, confirm with your IT team which data is allowed to leave the building.

If you're serious about this, start small. Build a function that takes a single cell's value, appends a system prompt, and returns a short answer. Test it on non-sensitive data. Then expand to ranges and more complex prompts. You'll quickly learn that the real skill isn't writing the API call; it's designing prompts that work at scale. And don't overlook the cost. Every call burns tokens, and a column of 10,000 rows will add up. Consider batching or using a cached response for repeated values. The takeaway is clear: you don't need to wait for Microsoft or Google to hand you the perfect function. The building blocks are already in your hands, and the only missing piece is the willingness to build. Watch how your own usage evolves, because the person who asks this question today is the one who will define what "AI-native spreadsheet" means tomorrow.

From Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community

I know Google Sheets has an “=AI” function for sheets and MS has “=copilot” for excel.

My company went with Open AI. Do they have a similar =“chatgpt”? Can I create one to use in ms excel with VBA combined with an api key? How can I get started?

Read the original at Microsoft Excel | Help & Support with your Formula, Macro, and VBA problems | A Reddit Community