Member-only story

How To Use ChatGPT Inside Excel

Shweta Lodha
3 min readMar 13, 2023

--

In this article, I will show you, how can you integrate ChatGPT with Microsoft Excel.

Let’s get started by getting an OpenAI API key.

Getting OpenAI API Key

To get the OpenAI key, you need to go to https://openai.com/, login and then grab the keys using highlighted way:

Adding Script In Excel

Let’s open Excel, go to Automate tab and click on New Script button on ribbon bar as shown below:

On clicking of New Script, a coding pane will open wherein we will be writing our script.

function main(workbook: ExcelScript.Workbook) 
{

}

Here are the few steps which need to be taken-

1. Setting up OpenAI key and endpoint

I grabbed the OpenAI key as shown above and then jotted it down in the same workbook, under sheet named MyKey , within B1 cell.

const apiKey = workbook.getWorksheet(“MyKey”).getRange(“B1”).getValue();
const endpoint: string = “https://api.openai.com/v1/completions";

--

--

Shweta Lodha
Shweta Lodha

Responses (3)