How to Extract the Missing Values through Excel VBA?
Tags: toextractthemissingv, vbamacros
Published: 2021-09-14 05:05:12

---
title: How to Extract the Missing Values through Excel VBA?
published: true
date: 2021-09-13 11:33:16 UTC
tags: ToExtractTheMissingV,VBAMacros
canonical_url: https://geekexcel.com/how-to-extract-the-missing-values-through-excel-vba/
---

In this tutorial, we will guide you on  **how to extract the missing values through Excel VBA**. Let’s get them below!! Get an 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)**

## User Defined Function

Microsoft Excel allows you to **create your own function** as per the requirement, we call it **User Defined Function**.

## Example

- 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 need to **insert a module**.
- After that, you have to go to **insert menu** and click on **procedure** , where you will get the procedure if you don’t know how it should be started the **macro**.
- You have to  **copy and paste**  the following code.

```
Function Missing_Number(Myrange As Range)
Dim Number(1 To 99) As Integer
On Error Resume Next
For Each Cell In Myrange
Number(Cell.Value) = 1
Next
On Error GoTo 0
Missing_Number = "Missing: "
For I = 1 To 99
If Not Number(I) = 1 Then
Missing_Number = Missing_Number & I & ","
End If
Next I
If Len(Missing_Number) = 9 Then
Missing_Number = Left(Missing_Number, Len(Missing_Number) - 2)
End If
End Function

```

- After that, you need to  **save the code**  by selecting it and then  **close the window**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Save-the-Code-31.png)

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- You need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://geekexcel.com/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Then, you have to use this **macro function** as formula given below.

```
=Missing_Number(D3:KO3)
```

- Now, you need to press **enter** on the keyboard
- Finally, you will get  **output ** as given below in the  **Microsoft Excel**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Output-6-1024x296.png)<figcaption>Output</figcaption>

## A Brief Synopsis

Here, we have explained the step-by-step procedure on **how to extract the missing values through Excel VBA**. Make use of this. Please share your worthwhile  **feedback**  in the below  **comment**  section. To learn more, check out our website **[Geek Excel](https://geekexcel.com/)!!**

**Read Next:**

- **[Excel Formulas to Highlight the Cells Between Two Dates!!](https://geekexcel.com/excel-formulas-to-highlight-the-cells-between-two-dates/)**
- **[Formulas to Find the Missing Values From a list!!](https://geekexcel.com/excel-formulas-find-missing-values-from-a-list/)**
- **[Excel Formulas to Find the Missing Value from a Range!!](https://geekexcel.com/excel-formulas-find-missing-value/)**
- **[Excel Formulas to Highlight the Missing Values ~ Easy Tutorial!!](https://geekexcel.com/excel-formulas-to-highlight-the-missing-values-easy-tutorial/)**
- **[How to Count missing values in a list in Excel Office 365?](https://geekexcel.com/how-to-count-missing-values-in-a-list-in-excel-office-365/)**