How To Build an Excel Add-In using VBA in Microsoft Excel?
Tags: tobuildanexceladdin, vbamacros
Published: 2021-10-08 01:53:05

---
title: How To Build an Excel Add-In using VBA in Microsoft Excel?
published: true
date: 2021-10-07 10:34:26 UTC
tags: ToBuildAnExcelAddIn,VBAMacros
canonical_url: https://geekexcel.com/how-to-build-an-excel-add-in-using-vba-in-microsoft-excel/
---

In this article, you will learn how to  **build an Excel Add-In using VBA** in Microsoft Excel. Let’s see them below!! Get the official version of  **MS Excel**  from the following link: [https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)

## Excel Add-Ins

- An **Excel Add-In is a file** (usually with an .xla or .xlam extension) that **Excel can load when it starts up**.
- The file contains **VBA code** that adds additional functionality to Excel, usually in the **form of new functions**.
- **Add-Ins** provide an excellent way of **increasing the power of Excel** , and they are the ideal vehicle for distributing your **custom functions**.
- Excel is shipped with a **variety of Add-Ins** ready for you to **load and start using** , and many **third-party Add-Ins** are also available.

## Add a code module to a new workbook

- Firstly, in the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://geekexcel.com/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to click on the  **Insert ** and select  **Module**.

![Insert a module](https://geekexcel.com/wp-content/uploads/2021/09/Insert-a-module.png)<figcaption>Insert a module</figcaption>

- After that, you have to  **copy and paste the code**  given below.

```

'Insert below code in Addin
Option Explicit

    
Function Age(DoB As Date)

'Gives a name to the function and declares that a single argument is needed, which must be a date.

'Checking whether Date of Birth is zero
If DoB = 0 Then
    Age = "type the correct Date of Birth"
Else
    'If Date of Birth is not zero, compare the current month value with the Date of Birth
    Select Case Month(Date)
        'If current month is before (i.e. less than) the month of date of birth,
        'then they have not had their birthday, so their age is this year minus their birth year minus 1
        Case Is < Month(DoB) Age = (Year(Date) - Year(DoB)) - 1 'If current month is same as the month of date of birth 'we need to know whether or not they have had their birthday yet Case Is = Month(DoB) 'If today date is equal to or past the day of their birthday, 'then they have had their birthday (or it is today) 'so their age is this year minus their birth year? 'otherwise their age is this year minus their birth year minus 1 If Day(Date) >= Day(DoB) Then
                Age = Year(Date) - Year(DoB)
            Else
                Age = Year(Date) - Year(DoB) - 1
            End If
        'If today?s month is after (i.e. greater than) the month of the person?s date of birth,
        'they have had their birthday, so their age is this year minus their birth year.
        Case Is > Month(DoB)
            Age = Year(Date) - Year(DoB)
    'Close the CASE statement
    End Select
'Close the IF statement
End If
                 
'Close the Function
End Function

```

- You need to **switch to Excel** and in your empty workbook, you have to **create a sample data** with **name and DOB**.

![](https://geekexcel.com/wp-content/uploads/2021/10/Sample-data-17.png)<figcaption>Sample data</figcaption>

- Then, in another cell, you have to **enter your function** as given below.

```
=Age(A1)
```

![](https://geekexcel.com/wp-content/uploads/2021/10/Enter-Formula.png)<figcaption>Enter Formula</figcaption>

- Now, you need to  **save the workbook as an Add-In** by selecting it and then  **close the window**.

![](https://geekexcel.com/wp-content/uploads/2021/10/Save-the-Code-24.png)<figcaption>Save as Excel Add-In</figcaption>

- After that, you have to **install the Add-In**.
- For that, you need to go to **Tools** and select **Add-Ins to open the Add-Ins dialog**.

![](https://geekexcel.com/wp-content/uploads/2021/10/Add-Ins.png)<figcaption>Add-Ins</figcaption>

- To **install your Add-In** , you have to **place a tick in the check-box** next to your **Add-In’s name** and **click OK.**

![](https://geekexcel.com/wp-content/uploads/2021/10/Install-Add-in.png)<figcaption>Install Add-ins</figcaption>

- Then, if your **Add-In is installed** , you will see it listed in the **Project Explorer panel** of the VB editor.
- Now, you have to **locate the module** containing your **functions** and make whatever **additions and changes** you want.
- After that, if your **Add-In is not installed** , you need to **find the Add-In file** and **double-click it to open it in Excel**.
- Finally, you will not be able to see it in the Excel window, but it will appear in the **VB editor’s Project Explorer**.

## Conclusion

We hope that this tutorial gives you guidelines on how to  **build an Excel Add-In using VBA** in Microsoft Excel. ** ** Please leave a comment in case of any  **queries,**  and don’t forget to mention your valuable  **suggestions**  as well. Thank you so much for Visiting Our Site!! Continue learning on **[Geek Excel](https://geekexcel.com/)!! **Read more on [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Continue Reading:**

- **[Excel Formulas to Build Gantt Chart by Week ~ Easy Tutorial!!](https://geekexcel.com/excel-formulas-to-build-gantt-chart-by-week-easy-tutorial/)**
- **[Excel Formulas to build a Gantt Chart with Conditional Formatting!!](https://geekexcel.com/excel-formulas-to-build-a-gantt-chart-conditional-formatting/)**
- **[Excel Formulas to Find the Same Date in Next Year ~ Simple Guide!!](https://geekexcel.com/excel-formulas-to-find-the-same-date-in-next-year/)**
- **[How to make Gantt charts by weeks in Excel 365?](https://geekexcel.com/how-to-make-gantt-charts-by-weeks-in-excel-365/)**
- **[How To Mail every Worksheet with address in cell A1 using VBA in Excel?](https://geekexcel.com/how-to-mail-every-worksheet-with-address-in-cell-a1-using-vba-in-excel/)**