Integrate ChatGPT Into Your Excel Workflows: A Free Tool for Business Users

Are you ready to supercharge your Excel spreadsheets with AI capabilities? Today, we're excited to share a free Excel macro spreadsheet that brings the power of ChatGPT directly into your worksheets. With this tool, you can leverage AI assistance right where you work – in your Excel cells.

 

What Does This Tool Do?

 This Excel workbook adds a custom `=chatgpt()` function that connects with OpenAI's API to bring AI capabilities directly into your spreadsheet cells. Whether analyzing data, drafting content, or seeking data insights, you can now access AI assistance without leaving Excel.

> Important: This tool is provided by Riveting Partners as a free community resource and is not affiliated with, endorsed by, or connected to OpenAI in any way. The VBA macro code we built is freely inspectable and can be copied and re-used by you without payment to Riveting Partners. We don't receive compensation from OpenAI or any other company for sharing this work. <

 

Powerful Features 

Data Range Analysis

The function can process both single cells and ranges of data. For example:

=ChatGPT("Analyst", "Analyze this sales data", A1:D10)

 

Real-world Applications 

1. Cost Analysis: Prompt against your business metrics and request efficiency calculations. The tool can process tables of data and return structured insights.

2. Content Generation: Use the Marketing_Writer profile to generate product descriptions, social media posts, or email templates directly in your spreadsheet.

3. Data Insights: The Analyst profile can help identify trends, anomalies, and patterns in your datasets.

 

Getting Started

Prerequisites

- A current version of Microsoft Excel

- Basic familiarity with Excel functions

- Your own OpenAI API key. The instructions in the spreadsheet show you how to get yours at:

https://platform.openai.com/api-keys

 

Initial Setup

1. Download the Excel workbook from our website's Products and Services section.

    https://www.rivetingpartners.com/aitools/p/excel-spreadsheet-with-chatgpt-function-available-for-use-in-cells

2. Open the "ChatGPT_Setup" tab

3. The spreadsheet is going to warn you that it includes macros. This warning is expected behavior.

4. Go to the ChatGPT_Setup sheet and replace the sample API key with your own OpenAI API key

5. Save the workbook

 

⚠️ Security Note: After adding your API key, we strongly recommend:

- Hide the ChatGPT_Setup sheet if you plan to share your spreadsheet with others.

- Password-protect the workbook's structure to prevent the sheet from being unhidden.

- Never share the workbook without first removing or hiding your API key

 

Using the ChatGPT Function

Basic Syntax

=ChatGPT("assistant_name", "your_prompt", [optional_data_ranges])

 

Key Things to Know

1. The workbook operates in manual calculation mode to prevent unnecessary API calls. You can change this setting in your spreadsheet.

2. After entering a ChatGPT formula into a cell (and waiting for it to pre-validate), press Shift+F9 to initiate the workbook re-calculation and receive your API response(s).

3. Responses may take a few seconds, depending on API response times.

 

Pre-configured Assistants

The workbook comes with five pre-built example assistants:

- Default: General-purpose helper

- SEO_Expert: Optimizes text for search visibility

- Marketing_Writer: Creates compelling marketing content

- Email_Writer: Crafts professional email messages

- Analyst: Provides data insights and analysis

 

You can modify these and add your assistants by extending the ChatGPT_Setup sheet with more columns to the right of the current assistants.

 

 

Best Practices

1. Cost Management

   - Think of input and output tokens like words. On average, 1,000 English words are about 750 tokens. OpenAI charges you for both the tokens in your Prompt and the tokens in the Response. Your Prompt includes the words in the variables in your "assistant" setup, the words in your Prompt, and the words in your data, if any. The tokens in the Response are the text returned, plus some other technical data that the chatgpt() function doesn't display. In a few of OpenAI's models, you are also charged for the "hidden" thinking tokens used in their reasoning model, where the model talks to itself to resolve your Prompt.

    - Current API pricing depends upon the model your Assistant calls, which you select in the ChatGPT_Setup sheet. As you can see in the bottom half of that sheet, the prices range from between 6 cents per thousand tokens (“o1” model output tokens) to 15 cents per million tokens (“gpt-4o-mini model input tokens).

    - Use specific, focused prompts. If you want a concise answer, then instruct the model, i.e.: “… Provide a detailed yet concise response within 900 tokens.” You can do this as part of your “prompt” variable in the chatgpt() formula or in the Assistant's "System Role" instructions in ChatGPT_Setup.

    - Leverage manual calculation mode to control API calls. "Shift-F9" to recalculate the sheet ONLY when ready to trigger the API call(s).

    - Different models have different costs per input and response token. If they can still deliver the desired results, use older models for lower costs. OpenAI’s “reasoning” models, i.e., "o1” and “o3”, not only have higher prices per million tokens, but they ALSO charge you for the "hidden" thinking tokens used by the model when generating a response. The o1 and o3 models are powerful but often overkill for many tasks. Experiment with the older, cheaper models before selecting the latest models.

   - Select the cheapest model that will get the results you need. Tokens range from 15 cents to $60 per million tokens, and that is a 400x difference in cost. Input and output tokens are priced differently. The “gpt-4o-mini" model is the cheapest during this writing. The ChatGPT_Setup sheet shows more data on current pricing, or go here:

https://openai.com/api/pricing/ or https://platform.openai.com/docs/pricing

   - Consider data volume when including data ranges in your prompts.

   - Set limits on your API key(s) from within your OpenAI account, here:

https://platform.openai.com/settings/organization/limits

   - Monitor your API token usage and spending here:

https://platform.openai.com/settings/organization/usage

   - Experiment with the “Maximum Response Tokens” variable in your assistant setup in the ChatGPT_Setup sheet to limit return answers and save tokens. However, this will truncate the Response rather than instruct the model to be more concise.

  

2. Performance Tips

   - Group related queries for more coherent analysis

   - Use cell references for frequently changed prompts

   - Test prompts with small data samples first. Test a few rows or columns before copying the chatgpt() formula down the line.

   - Reasoning models take longer to respond. Select older or "mini" models for the fastest response times. Each "=chatgpt()" is a separate prompt, and the time delay can add up quickly.

Technical Details

- The workbook includes robust error handling.

- The workbook includes robust rate-limiting variables in the ChatGPT_Setup sheet, which you can use if the API call hits rate limits.

- All macro code is open for review, copying, and re-use in the VBA editor. Press Alt+F11 while the spreadsheet is open to inspect the VBA macro code. You can even copy all of the code to ChatGPT and ask it to advise you about security risks!

- The ChatGPT_Setup sheet allows for the customization of API parameters. Each Assistant can have its own parameters. You can modify the existing assistants or add more simply by adding more columns to the right of the existing assistants.

 

Limitations and Considerations

- Each cell containing a ChatGPT formula will consume API tokens (and thus cost money).

- Response times vary based on API performance.

- The tool requires manual calculation (Shift+F9) to update responses.

 

Get Involved

We built this tool to help the community integrate AI into daily workflows. We'd love to hear your:

- Use cases and success stories.

- Feature requests.

- Suggestions for improvements.

- Questions about implementation.

 

Next Steps

1. Get your OpenAI API key from OpenAI's website (see instructions in the spreadsheet).

2. Download the workbook from our Products section.

3. Follow the setup instructions in the workbook.

4. Start experimenting with AI-powered Excel functions!

Remember: Your API key is required for the tool to work, and you're responsible for any API usage costs from OpenAI. The API key included in the spreadsheet has been revoked but left in place to show an example of what one might look like. We don’t make any money from this, and we're just looking for feedback from the community.

 ---

 Do you have questions or feedback? We'd love to hear from you at AITools@RivetingPartners.com or in the comments below! Let us know if we can create a customized solution for your business.