Start using GPT functions in Excel
GPT functions are custom spreadsheet functions in GPT for Excel that allow you to prompt AI from inside spreadsheet cells. GPT functions work exactly like native functions in that you can use them on their own or combine them with other functions when creating formulas.
This guide walks you through the basics of using GPT functions — from enabling GPT functions for a workbook through building formulas with GPT functions to using functions for web search and image processing. The focus is on the GPT
function, the simplest function included in GPT for Excel, but the same rules apply to all GPT functions.
To try out the examples in this guide, download our GPT function starter examples template, and open it in Excel as a new workbook.
Enable GPT functions
GPT for Excel must be running before you can use GPT functions for the first time in a workbook.
To start GPT for Excel:
Open the workbook where you want to use GPT functions.
In the Home tab, click GPT for Excel Word.
infoYou can also select Home > Add-ins > My Add-ins > GPT for Excel Word.
Use GPT functions
Learn the basics of using GPT functions, from how you type a function through how you use functions in formulas to how you search the web and process images with functions.
GPT function syntax
Each GPT function follows a specific syntax that consists of a function name and one or more parameters (also called "arguments") enclosed in parentheses. The parameters together tell the function what to do. Some parameters are required, while others are optional. The syntax of a function is presented as follows:
The order of the parameters matters, so always write them in the order required by the function syntax. Optional parameters are in square brackets.
For example, the GPT
function has the following syntax:
The GPT
function takes the following four parameters:
Parameter | Required | Description |
---|---|---|
| Yes | The prompt for the AI. The prompt can be:
|
| No | Input that you want to combine with the prompt. The input can be:
If you provide For example, if info The If you do not provide |
| No | Number between
|
| No | Name of the AI model that you want to use. You can find the model names in the model switcher in the add-in sidebar. Learn more. |
The first parameter of the GPT
function is required, so you always have to provide it. The remaining three parameters are optional, so you only need to provide them when you want additional control over how the function operates. You can provide one, two, or all three optional parameters, depending on your needs.
If a parameter takes a text value, always enclose the text in double quotation marks. For example:
✅ GPT("Write a tagline for a tea house")
❌ GPT(Write a tagline for a tea house)
The latter fails with an error because the function cannot interpret the words as valid parameters.
If you skip an optional parameter other than the last one, always provide a lone comma ("empty parameter") as a placeholder to maintain the correct syntax. For example:
✅ GPT("Write a tagline for a tea house", , 0.5, "claude-4-sonnet")
❌ GPT("Write a tagline for a tea house", 0.5, "claude-4-sonnet")
The latter fails with an error because the function treats 0.5
as the second parameter (value
, which expects text or a reference) and "claude-4-sonnet"
as the third parameter (temperature
, which expects a number).
Run a GPT function
To use the GPT
function:
Select a cell where you want the response to appear.
Type the equal sign
=
followed by the function. For example, to use theGPT
function with just theprompt
parameter, type:=GPT("Write a tagline for a tea house")
Press ENTER.
The function runs: It sends the prompt to the AI, receives a response, and displays the response in the selected cell.
The text you see in the cell is the result of the formula — a dynamically calculated value. The actual value of the cell is the formula expression: =GPT("Write a tagline for a tea house")
. You cannot edit the result; you can only edit the formula. If you want to set the result as the actual value of the cell, that is, if you want to turn the calculated value into a constant that you can edit, replace the formula with its result.

Reference other cells from a GPT function
You can reference other cells and ranges from a GPT function. You can use relative, absolute, and mixed references as you would with any function.
For example, to retrieve the prompt for the GPT
function from another cell:
Select a cell and enter the prompt:
Write a tagline for a tea house
tipYou do not need double quotation marks around the prompt here because Excel automatically returns the value as text.
Select another cell and enter the
GPT
function with the prompt cell as the only parameter. For example, if the prompt is in cellB12
, enter:=GPT(B12)
The function runs and returns the AI's response in the selected cell.
Both GPT(B12)
and GPT("Write a tagline for a tea house")
work the same way — they send the exact same prompt to the AI. The only difference is that the former retrieves the prompt from a cell, while the latter provides it directly as a text constant in the function.
Apply the same prompt to multiple cells
You can apply the same GPT function and prompt to adjacent cells by filling the formula across a range.
For example, suppose you want to generate unique taglines for multiple businesses. The businesses are listed in one column of your sheet, and you want to fill another column with the corresponding taglines. You can generate the taglines by using the GPT
function with the prompt
and value
parameters, where prompt
specifies the basic instructions and value
specifies a specific business as a cell reference:
Select the first tagline cell and enter the
GPT
function. For example, if the business whose tagline you're generating is specified in cellB7
, enter:=GPT("Write a tagline", B7)
The function combines the two parameters into a single prompt, based on the underlying prompt template, which is then sent to the AI. For example, if
B7
contains the textantique store
, the final prompt sent to the AI is:The function runs and returns the AI's response in the selected cell.
Fill the formula down to apply it to the rest of the column: Select the fill handle and drag it down across the cells you want to fill. Excel automatically updates the cell reference in the function so that each row receives a tailored response based on its business. The formula in row 8 will reference
B8
, the formula in row 9 will referenceB9
, and so on.
To see how absolute references work, let's move the prompt to its own cell:
Select an empty cell and enter the prompt:
Write a tagline
Select the first tagline cell and update the
GPT
function to reference the prompt cell. For example, if the prompt is in cellC8
and the business whose tagline you're generating is now specified in cellB11
, enter:=GPT($C$8, B11)
$C$8
is an absolute reference toC8
, which you need here since you do not want Excel to automatically adjust the reference when you fill the formula to adjacent cells.tipSince you're only filling vertically across a single column, it would be enough to fix the prompt cell row using a mixed reference:
=GPT(C$8, B11)
Fill the formula down to apply it to the rest of the column: Select the fill handle and drag it down across the cells you want to fill, overwriting the existing formulas. Excel automatically updates the value cell reference for each row, while keeping the prompt cell reference fixed.
Create a prompt by combining text from multiple cells
You can use concatenation to combine text from two or more cells into a single text string. This allows you to create advanced prompts, where different parts of the prompt come from different cells in the sheet.
For example, suppose you want to further customize the taglines of the previous example, so that they follow a specific tone and target a specific customer age range. The businesses are listed in the first column, the tone in the second, and the age range in the third, with the fourth column now reserved for the taglines.
To build the prompt by combining the information from the different columns:
Select the first tagline cell and enter the
GPT
function. For example, if the business whose tagline you're generating is specified in cellB11
, with the tone in cellC11
and age range in cellD11
, enter the following in cellE11
:=GPT("Write a tagline for " & B11 & ", the tone is " & C11 & ", the audience is aged " & D11)
The function uses the
&
operator to concatenate the different parts, which include literal text values and cell references, into a single text string. For example, ifB11
contains the textantique store
,C11
containsnostalgic and refined
, andD11
contains35-65
, the final prompt sent to the AI is:tipInstead of the
&
operator, you can also use the nativeCONCAT
function:=GPT(CONCAT("Write a tagline for ", B11, ", the tone is ", C11, ", the audience is aged ", D11))
The
GPT
function uses theCONCAT
function as a nested function. Learn more.If you want to concatenate without having to worry about white spaces and newlines, use the
GPT_CREATE_PROMPT
function:=GPT(GPT_CREATE_PROMPT("Write a tagline for", B11, ", the tone is", C11, ", the audience is aged", D11))
Fill the formula down to apply it to the rest of the column: Select the fill handle and drag it down across the cells you want to fill. Excel automatically updates the cell references in the function so that each row receives a tailored response based on its business. The formula in row 12 will reference
B12
,C12
, andD12
; the formula in row 13 will referenceB13
,C13
, andD13
; and so on.
Combine a GPT function with a native function
You can combine GPT functions with native functions like you would any other function.
For example, suppose you want to run the GPT
function from above only when the current row has a business specified. If the business cell is empty, you want to skip the row. You can do this by combining the GPT
function with the native IF
function:
Select the first tagline cell and enter a formula that wraps
GPT
inside anIF
function. For example, if the business whose tagline you're generating is specified in cellB11
and the GPT function for that isGPT($C$8, B11)
, enter:=IF(B11="", "", GPT($C$8, B11))
The
GPT
function runs only if cellB11
is not empty. IfB11
is empty, the formula leaves the current cell empty, too.Fill the formula down to apply it to the rest of the column: Select the fill handle and drag it down across the cells you want to fill, overwriting the existing formulas. Excel automatically updates the value cell reference for each row, while keeping the prompt cell reference fixed.
To see the conditional logic in action, empty one of the business cells. The formula for that row reruns and removes the tagline.
Search the web with a GPT function
You can search the web with a GPT function simply by using a web search model. You can either select the model in the model switcher or specify the model with the model
parameter.
For example, suppose you want to do a search for company CEOs. The companies are listed in one column of your sheet, and you want to fill the next column with the CEO names.
In the sidebar, expand the model switcher and select a web search model (indicated by the 🌐 icon).
infoIf you select a Gemini model, make sure web search is enabled for Gemini models.
Select the first CEO cell and enter the GPT function. For example, if the company whose CEO you're fetching is specified in cell
B13
, enter:=GPT("Give me this company's current CEO. I only want the name of the CEO, no citations.", B13)
tipIf you want to override the model switcher selection, specify the model in the GPT function with the
model
parameter. For example, if you want to use the Sonar model, enter:=GPT("Give me this company's current CEO. I only want the name of the CEO, no citations.", B13, , "sonar")
Fill the formula down to apply it to the rest of the column: Select the fill handle and drag it down across the cells you want to fill. Excel automatically updates the company cell reference for each row.
For more information about web search, see Search the web with GPT for Excel.
Process images with GPT_VISION
You can apply a text prompt to an image using the GPT_VISION
function with a vision model. You can either select the model in the model switcher or specify the model with the model
parameter.
For example, suppose you want to extract the brand name from product images featuring coffee bean packs. The image URLs are listed in one column of your sheet, and you want to fill the next column with the brand names.
In the sidebar, expand the model switcher and select a vision model.
To determine whether a model supports vision, check its info popup. For a list of available vision models, see AI providers & models and filter the tables by Vision.
Select the first image URL cell and enter the GPT function. For example, if the image URL that you want to process is in cell
C13
, enter:=GPT_VISION("Extract the coffee brand from this image. Normalize the brand name to title case.", C13)
tipIf you want to override the model switcher selection, specify the model in the GPT function with the
model
parameter. For example, if you want to use the Claude Sonnet 4 model, enter:=GPT_VISION("Extract the coffee brand from this image. Normalize the brand name to title case.", C13, , , "claude-4-sonnet")
Fill the formula down to apply it to the rest of the column: Select the fill handle and drag it down across the cells you want to fill. Excel automatically updates the image URL cell reference for each row.
For more information about AI vision, see Use images in prompts in Excel.
Set the model for a GPT function
You can run a GPT function with a specific model by providing the model
parameter. The function will ignore what's currently selected in the model switcher and use the provided model instead.
For example, if you want the Perplexity Sonar model to answer a query about current events, provide sonar
as the model:
=GPT("What was the previous month's inflation rate in the US?", , , "sonar")
If the model is available both with and without an API key in GPT for Excel, the function uses the model with the API key.
Use the model
parameter when:
You want to lock a formula to a specific model. For example, if you have a web search formula, you want it to consistently use the same web search model.
You want to compare how a specific model compares with other models. For example, use the same GPT function and prompt in two formulas — the first with the
model
parameter, the second without — and then use the model switcher to change the model used by the second formula, regenerating its response after each change.
Set the creativity level for a GPT function
You can run a GPT function with a specific creativity level by providing the temperature
parameter. The function will ignore the creativity level defined in the model settings and use the provided level instead.
For example, if you're working on a creative task and want to experiment with highly creative responses, set the temperature close to 1
:
=GPT("Write a three-sentence horror story about a teahouse.", , 0.9);
For more information about temperature, see our temperature guide for OpenAI models.
GPT functions: Defaults, settings, behavior
Default model
By default, GPT functions use the currently selected model. If you want a GPT function to use a specific model regardless of what's currently selected in the model switcher, use the model
parameter to explicitly set the model.
If you provide the model
parameter, and if the model is available both with and without an API key in GPT for Excel, the function uses the model with the API key.
Default creativity level
By default, GPT functions use the creativity level defined in the model settings. If you want a GPT function to use a specific creativity level regardless of what's defined the model settings, use the temperature
parameter to explicitly set the creativity level.
Global instructions and advanced settings
The global instructions and advanced settings defined in the GPT for Excel sidebar apply to GPT functions. If you find that a function is not working as expected, check the model settings for a possible cause.
Regional settings
The default characters used by Excel for parameter and decimal separators depend on your currently selected region:
Parameters: Some regions use the comma (
,
) as the default parameter separator, while others use the semicolon (;
).Decimals: Some regions use the period (
.
) as the default decimal separator, while others use the comma (,
). As a rule, regions that use the period for decimals use the comma for parameters, whereas regions that use the comma for decimals use the semicolon for parameters.
The examples in the current documentation use the comma as the parameter separator and the period as the decimal separator. If the examples fail with syntax errors in your workbook, check your regional settings to verify which punctuation to use.
Formula auto-refresh
When your sheet auto-refreshes, Excel automatically recalculates some or all formulas on the sheet, including GPT formulas. For each GPT formula:
If the GPT formula cache is enabled for the workbook, Excel reuses the formula's previously generated result from the cache.
If the cached result has expired, or if you have the cache disabled, Excel runs the formula normally.
In Excel, the following triggers cause a sheet to auto-refresh:
Recalculation trigger | What gets recalculated |
---|---|
Insert, move, or delete a column | All formulas on the sheet |
Insert, move, or delete a row | All formulas on the sheet |
Filter rows by column | All formulas on the sheet |
Hide and unhide rows | Formulas in the selected rows |
Sort rows | Formulas in the selected rows |
Move a formula to a different cell | All formulas on the sheet |
Undo the deletion of a formula from a cell | Restored formula |
To prevent GPT formulas from being recalculated, replace the formulas with their results.
When to use bulk AI tools
Consider using bulk AI tools instead of GPT functions if:
You want AI responses saved as plain text in cells. Bulk AI tools fill cells with static text values, or constants, so you don't need to replace any formulas. You also avoid formula auto-refresh, reducing the risk of unintended data changes.
You want better tracking information about the progress of AI requests. Bulk AI tools provide a live progress tracker that shows you how many rows have been successfully processed, how many have resulted in an error, and how much time has elapsed.
Your formulas regularly become stuck in the #BUSY! state.
What's next
Learn how to use each GPT function with a real-world example.
Try out example use cases for different business applications and product capabilities.
Browse all our GPT function resources.
Select the model that best fits your needs.
Configure the model settings to customize how the currently selected model operates.