We may earn compensation from some listings on this page. Learn More

How to Use ChatGPT with Microsoft Excel

Mar 31, 2023

ChatGPT is an excellent AI chatbot that can help reduce workload by generating content, writing codes, answering questions, and much more. Microsoft Excel is an office product that allows users to organize, format, and calculate data in a sheet. 

With the availability of ChatGPT API, users can integrate ChatGPT with Excel and use it for greater benefits such as easily accessing data, organizing information, editing responses, and more.

In this article, we discuss how to harness the power of ChatGPT within Microsoft Excel, detailing the prerequisites and functionalities involved. Learn how to set up ChatGPT in Excel, explore the benefits of this integration, and discover some best practices for getting the most out of the combined features.

How to Use ChatGPT with Microsoft Excel


To use ChatGPT with Microsoft Excel you will require two important things: API Key and VBA code. You need to generate the API Key by visiting the ChatGPT API website and generating your secret API Key.

While You can find the VBA code through this link you can simply copy the code or ask ChatGPT to generate VBA Code for you. 

Once Chatgpt has generated the code, you can copy the code and add it to the Module in your Excel sheet.

After you have pasted the VBA code on the Excel module, you need to add your secret API Key on the top section that says “API Key” and assign macros to the quick access bar. Once done, you need to save a VBA to an Excel file and ChatGPT and you can start using ChatGPT with Microsoft Excel.     

Explanation of the integration with Microsoft Excel


OpenAI released a ChatGPT API that allows developers to integrate ChatGPT in other web applications. They even contain a python package that can be used for the same, however, they have no official add-on for MS Excel. 

But since we have an API, we can use the API Key in the MS Excel worksheet using a VBA Code. VBA code is a programming language that is used for generating Excel Macros which can help automate repetitive tasks.

In the VBA Code, we add the secret API Key to enable the integration between ChatGPT and Excel. 

Also Read – How to Use ChatGPT as a Language Translation Tool

Setting up ChatGPT in Microsoft Excel


Here are the steps that you need to follow to set up ChatGPT in Microsoft Excel: 

Get your API Key 

  • Go to the homepage of ChatGPT API Key using this key 
  • Login or Create a free account using your email  
  • Tap on “Personal” option on available on the upper right corner 
  • Select “View API Key” and generate your key by clicking on “Create new secret key” 

Open Excel Workbook 

  • Open a new Excel workbook and select “Developer” at the top section
  • Now click on “Record Macro” under store macro in the option select “Personal Macro Workbook” in the drop-down field
  • Now, you can stop recording 

Add VBN 

  • Open Visual Basic Editor at the left corner and a new “personal.xlsb” section will appear 
  • Open the section and move to “model” and open “Module 1”
  • Now, you need to add the VBA Code  
  • You can find the VBA Code through this link VBN Code, simply copy the code and add it to Module 1
  • In this code, you will find the “API KEY” section available at the top, you need to replace it will your “API Key code” which you generate at the beginning

Add Macros to Quick Access Toolbar 

  • Now, assign this macro to the Quick Access toolbar so, click on the arrow key available at the top-left corner, and choose “More Commands” 
  • In the new windows, choose macro, and in <Separator> add Personal workbook to your Quick Access Bar 
  • You can even modify the button icon to make it easier to identify
  • Now click on “Ok” 

Save VBA Code to Excel 

  • When you close the workbook, a pop will appear asking you to save changes to your Personal workbook, click on “Save” to make the VBA code available to Excel files
  • Open A New Spreadsheet in Excel 
  • Enter your prompt in any cell, select that cell, and run the VBA code from the Quick Access toolbar 
  • The response from AI Chatbot ChatGPT will appear in a new worksheet 

Requirements and Pre-requisites


You need to generate your ChatGPT API Key before integrating ChatGPT with Microsoft excel. ChatGPT API provides a free trial of $18 which usually lasts about 3 months.

If you have already used the free tokens then, we suggest you purchase tokens to use API keys. 

Since you can integrate ChatGPT with Excel without the Key. Another thing you should do is generate the VBA code. You can get the VBA code through this which will help you integrate ChatGPT with Excel. 

Installing and enabling the ChatGPT add-on


ChatGPT doesn’t have an official API available for Excel. However, you can use the ChatGPT API to integrate and add ChatGPT using the API Key to your excel worksheet. 

ChatGPT Functionalities in Excel


Here are some of the functionalities of ChatGPT in Excel: 

  • Helps users edit responses generated by ChatGPT easily in the Excel sheet itself
  • Easy to format with several formatting options available in Excel 
  • Simple and accessible for organizing data in a structured format
  • Excel worksheets are utilized as a Dashboarding tool, therefore integrating ChatGPT with Excel will help generate insights, and help identify trends and make informed decisions

Collaboration and Communication using ChatGPT


Once you have integrated ChatGPT in Microsoft Excel, users can simply type in their questions in any cell present in your Excel Sheet.

After you have written your prompt, click on that particular cell and run the VBA code from the Quick Access toolbar. Within a few seconds, ChatGPT will generate the response in a new worksheet. 

Tips and Best Practices


Here are some of the best tips that can be helpful during the integration of ChatGPT and Excel: 

  • While assigning a macro to the Quick Access toolbar, choose a modifying icon, like a “smiley” or “star” this will help you easily identify your icon from the toolbar. 
  • If you are unable to find the VBA code then you can use ChatGPT to generate the VBA Code. Simply type in your prompt and use the generated code on module 1 for the integration. 
  • Your API key will stop working, once your free credit is over. So, if your API Key stopped working then it’s time for you to purchase API tokens for further usage. 

Conclusion


Integrating ChatGPT in Microsoft Excel can help reduce users’ workload and generate data and information without the need to switch from one tab to another. By generating an API Key and VBA code users can easily integrate the AI chatbot with an Excel worksheet. Above we have mentioned proper steps on how to use ChatGPT with Microsoft Excel, which will help you integrate the chatbot with Excel.  

Related Articles

  1. Microsoft Adds OpenAI ChatGPT to Word, Excel, & Outlook
  2. ChatGPT Desktop App for Windows PC & Mac
  3. Integrate ChatGPT into Microsoft Word