How to Create a Custom Excel Add-in (Step-by-Step Guide)
Build your own Excel add-in: save a macro-enabled workbook, add a custom ribbon tab with the free Office RibbonX Editor, wire each button to a VBA routine, then save the file as an .xlam and install it. The example adds a ChatGPT button and two IFERROR helpers, but the ribbon pattern works for any macro.
Update (November 2026): The ChatGPT macro in the video calls text-davinci-003, which OpenAI retired in January 2024, so take the updated mChatGPT.bas from the GitHub repo; the ribbon steps are unchanged.
Table of contents
Save a macro-enabled workbook
An add-in starts as an ordinary workbook that can hold macros. Open a new, empty workbook, go to File > Save As and pick Excel Macro-Enabled Workbook (*.xlsm). You turn it into an add-in at the very end.

Add a ribbon tab
The ribbon of an add-in is an XML file stored inside the workbook. The free Office RibbonX Editor writes that file for you. Download it from its GitHub release page. Version 1.9.0 is still the latest, in a .NET Framework build and a .NET 6 build. The SelfContained .NET 6 installer brings its own runtime, so you do not need to install .NET separately.

Install it with the default settings, close Excel, and open your .xlsm in the editor. Right-click the file and choose Insert Office 2010+ Custom UI Part.

Double-click the new customUI14.xml part and paste the XML for a tab with one large button. The editor also has examples under Insert > Sample XML. This is the version I start from:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="CustomTab" label="My Tab">
<group id="SimpleControls" label="My Group">
<button id="Button1" imageMso="HappyFace" size="large"
label="Large Button"
screentip="my long description"
onAction="MyMacro"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Two details matter. startFromScratch="false" keeps Excel’s own tabs; with true, your tab would be the only one. And onAction names the macro without a ThisWorkbook. prefix, so it calls a sub in a normal module. Click Validate to check the XML, save, and open the workbook in Excel. A new My Tab appears with a large button.

Wire the button to a macro
The button runs the macro named in onAction, here MyMacro. Until that macro exists, a click only shows an error.

Open the Visual Basic Editor from the Developer tab. If you do not see that tab, right-click the ribbon, choose Customize the Ribbon and tick Developer. Insert a module and add a sub with exactly the name from the XML. A ribbon callback takes the clicked control as its argument:
Option Explicit
Public Sub MyMacro(ByRef control As Office.IRibbonControl)
Call MsgBox("Hello large button")
End Sub
Click the button again and the message box appears.
Add the ChatGPT button
Any macro can sit behind the button. In the video it is a ChatGPT macro: it sends the selected cell to the OpenAI API and writes the answer to a worksheet called Result.
I explain that macro in bringing ChatGPT into Excel. Import mChatGPT.bas from the GitHub repo instead of copying the code from the video, because the model in the original macro no longer exists. Paste your OpenAI API key into the API_KEY constant. The top of the updated module looks like this:
Option Explicit
'#################################################################################
'## Title: ChatGPT Chat Completions using OpenAI API
'## Author: Sven from CodingIsFun
'## Website: https://pythonandvba.com
'## YouTube: https://youtube.com/@codingisfun
'##
'## Updated: November 2026 (text-davinci-003 and the "completions" endpoint were shut down
'## by OpenAI, so the script now uses the "chat/completions" endpoint)
'##
'## Description: This VBA script uses the OpenAI API endpoint "chat/completions" to generate
'## a text completion based on the selected cell and displays the result in a
'## worksheet called OUTPUT_WORKSHEET. If the worksheet does not exist, it will be
'## created. The API key is required to use the API, and it should be added as a
'## constant at the top of the script.
'## To get an API key, sign up at https://platform.openai.com/api-keys
'#################################################################################
'=====================================================
' GET YOUR API KEY: https://platform.openai.com/api-keys
Const API_KEY As String = "<API_KEY>"
'=====================================================
' Constants for API endpoint and request properties
Const API_ENDPOINT As String = "https://api.openai.com/v1/chat/completions"
' MODEL: change this line to use another OpenAI model.
' List of current models: https://developers.openai.com/api/docs/models
Const MODEL As String = "gpt-6-luna"
' Maximum number of tokens the model may generate (this includes its internal reasoning)
Const MAX_TOKENS As String = "4096"
' Reasoning effort: "low" keeps answers fast and cheap. Other options: "medium", "high"
' (Current GPT models no longer accept the old "temperature" setting together with reasoning.)
Const REASONING_EFFORT As String = "low"
'Output worksheet name
Const OUTPUT_WORKSHEET As String = "Result"
Then adjust the XML: rename the tab, label the group ChatGPT, and point onAction at the ChatGPT macro, OpenAI_Completion in the repo. For the icon, use a built-in imageMso name or your own picture. Custom images look best at 32×32 pixels. Insert the file into the project with the editor’s Insert Icons button and reference it with image="ai" instead of imageMso. Validate, save and reopen the workbook. Select a cell with a prompt, click the button, and the answer lands on the Result sheet.

Add a second group
A second group holds smaller utility buttons. Insert another module and paste mIfError.bas from the repo. It has two macros that wrap the formulas of the selected cells in IFERROR, one returning a blank and one returning zero.
'*******************************************************************************
'*
'* Author: Sven from CodingIsFun
'* Website: https://pythonandvba.com
'* YouTube: https://youtube.com/@codingisfun
'*
'* This module contains two macros:
'* - IfErrorBlank: Adds an IFERROR function to selected cells and returns a blank cell if an error occurs
'* - IfErrorZero: Adds an IFERROR function to selected cells and returns zero if an error occurs
'*
'*******************************************************************************
Option Explicit
Public Sub IfErrorBlank(control As IRibbonControl)
'Add an IFERROR function to all selected cells with a formula and return a blank cell if an error occurs
Dim cell As Range
On Error Resume Next
For Each cell In Selection.Cells
If cell.HasFormula And Not cell.HasArray Then
'Add the IFERROR function to the formula
cell.formula = AddIfError(cell.formula, """""")
End If
Next cell
On Error GoTo 0
End Sub
Public Sub IfErrorZero(control As IRibbonControl)
'Add an IFERROR function to all selected cells with a formula and return zero if an error occurs
Dim cell As Range
On Error Resume Next
For Each cell In Selection.Cells
If cell.HasFormula And Not cell.HasArray Then
'Add the IFERROR function to the formula
cell.formula = AddIfError(cell.formula, 0)
End If
Next cell
On Error GoTo 0
End Sub
Private Function AddIfError(ByVal formula As String, ByVal errorValue As Variant) As String
'Adds an IFERROR function to the formula and returns the specified error value if an error occurs
Dim formulaSeparator As String
'Determine the formula separator for the current language settings
formulaSeparator = Application.International(xlListSeparator)
'Add the IFERROR function to the formula
AddIfError = "=IFERROR(" & Right(formula, Len(formula) - Len(formulaSeparator)) & formulaSeparator & errorValue & ")"
End Function
Both subs take control As IRibbonControl, which every ribbon callback needs. In the editor, copy the group tag, give it a new id and label, and add one button per macro. This is the complete XML of the finished add-in in the repo:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="ChatGPT" label="ChatGPT">
<group id="AskChatGPT" label="Ask ChatGPT">
<button id="AskButton" label="Ask ChatGPT" onAction="OpenAI_Completion" image="ai" size="large" />
</group>
<group id="Utils" label="Utils">
<button id="IfErrorBlank" label="IfErrorBlank" onAction="IfErrorBlank" imageMso="EqualSign" size="normal" />
<button id="IfErrorZero" label="IfErrorZero" onAction="IfErrorZero" imageMso="EqualSign" size="normal" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
After you validate and reopen the workbook, the Utils group shows the two new buttons.

Save and share the .xlam
The add-in itself is the same workbook saved as an Excel Add-in (.xlam). Delete any extra sheets, clear the first sheet, choose File > Save As with the type Excel Add-in (*.xlam), and close Excel.

To share it, send the .xlam file. To install it, open Excel, go to File > Options > Add-ins and click Go next to Excel Add-ins. Click Browse, copy the file into the default add-in folder that opens, select it, and make sure it is ticked before you click OK. If Excel blocks the file because it came from the internet, right-click it, choose Properties and tick Unblock first. Mac users follow different steps, which I cover in installing an Excel add-in on a Mac.

From now on the tab shows up in every workbook you open.

Once your add-in grows beyond a few macros, writing the VBA in a proper editor helps. I show my setup in writing Excel VBA in VS Code, and my collection of free VBA libraries saves you writing common helpers from scratch.
Resources
- GitHub repo (workbook, mChatGPT.bas, mIfError.bas)
- Office RibbonX Editor 1.9.0
- imageMso icon list (names of the built-in Office icons)
