Need a hand? Happy to help.

How to use ChatGPT in Google Sheets

Using ChatGPT in Google Sheets for Automated Data Research

This setup lets you send prompts to ChatGPT directly from a Google Sheet — and pull the replies straight into your cells. You can research companies, write blurbs, even generate copy for every row in your spreadsheet. If you’ve got a list and a task, this saves you hours. Here’s how it works.

Why bother doing this

If you’ve ever tried to run ChatGPT prompts on a hundred companies manually, you know it’s painful. Copy. Paste. Repeat. This approach turns Google Sheets into an interface for bulk GPT. You type a formula like =COMPANY_DEEP_DIVE(A2) and boom — it fetches a company summary and drops it in the next column. No messing around with exports or browser tabs.

Here’s the code

Drop this into Apps Script. Go to Extensions → Apps Script in your Sheet, paste it in, and save:

const OPENAI_API_KEY = PropertiesService.getScriptProperties().getProperty('OPENAI_API_KEY');

function CALL_OPEN_AI(prompt, input) {
  const payload = {
    model: 'gpt-4o',
    messages: [
      { role: 'system', content: prompt },
      { role: 'user', content: input }
    ]
  };

  const options = {
    method: 'post',
    contentType: 'application/json',
    headers: {
      Authorization: 'Bearer ' + OPENAI_API_KEY
    },
    payload: JSON.stringify(payload)
  };

  const response = UrlFetchApp.fetch('https://api.openai.com/v1/chat/completions', options);
  const json = JSON.parse(response.getContentText());
  return json.choices[0].message.content.trim();
}

function COMPANY_DEEP_DIVE(companyName) {
  const prompt = `Give me a detailed overview of ${companyName}. Include:
    - Company background and origin story
    - What product(s) or service(s) they offer
    - Target market or audience
    - Business model or how they make money
    - Any unique selling points or innovations
    - Recent news, achievements or updates (if any)
    - Key people or founders
    - Challenges or controversies (if relevant)
    - Future plans or growth strategy

    Make it thorough, engaging, and formatted in clear sections.`;

  return CALL_OPEN_AI(prompt, '');
}

What to do next

1. Create a new Sheet or use an existing one with company names in a column. 2. In the cell next to your first company, type =COMPANY_DEEP_DIVE(A2). 3. Hit enter — and wait for the response to load. It takes a few seconds.

If you want something more flexible, you can use =CALL_OPEN_AI("your prompt", A2) and swap out the prompt as needed.

How to get your API key

Visit platform.openai.com. Log in, go to API keys, and create a new one. Add your card (they charge per use — usually a few cents per request). Then save that key in Apps Script → Project Settings → Script Properties under the name OPENAI_API_KEY.

Good to know

  • Each prompt costs money. Keep them short where possible.
  • Responses can include markdown. Tell it to give you plain text if needed.
  • Store keys in script properties, not your code — keeps things tidy and secure.
  • You can build more custom functions like =GET_TAGLINE() or =BRAND_SUMMARY() using the same pattern.

Why this matters

This turns Google Sheets into a lightweight content engine. It’s fast, low-code, and dead simple once it’s set up. You can scale tasks that would normally take hours, and keep your content consistent across pages, listings, and internal tools.

Final thought

It’s a bit cooked, but it works. If you want to move fast and get a result without over-engineering things — this is the way. The code’s here, the setup’s done, and you’ve got a clean workflow that plugs right into whatever else you’re building.

Watch the full setup in action here

Get in touch