how to Extract Specific Color Index using excel VBA?
Tags: toextractspecificcol, vbamacros
Published: 2021-09-22 09:34:59

---
title: how to Extract Specific Color Index using excel VBA?
published: true
date: 2021-09-18 02:19:25 UTC
tags: ToExtractSpecificCol,VBAMacros
canonical_url: https://geekexcel.com/how-to-extract-specific-color-index-using-excel-vba/
---

In this tutorial, we will guide you on how to **extract specific color indexes** using 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)**

## Example

- Firstly, you need to  **create a UDF** to show the **colored cells** only in **column B.**

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

- 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  **copy and paste the code**  given below.

```
Function IsYellow(ByRef r As Range)
    If r.Interior.ColorIndex = 6 Then
       IsYellow = r.Value
    Else
        IsYellow = vbNullString
    End If
End Function

```

- 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-48.png)<figcaption>Save the Code</figcaption>

- 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>

- Now, in **cell B1** , you have to use the formula given below.

```
=IsYellow(A1)
```

- Finally, you will receive the  **output ** in the  **Microsoft Excel**.

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

## A Brief Synopsis

Here, we have explained the step-by-step procedure on how to **extract specific color indexes** using 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 Ahead:**

- **[Excel Formulas to Highlight the Cells Between Two Dates!!](https://geekexcel.com/excel-formulas-to-highlight-the-cells-between-two-dates/)**
- **[Extract the Missing Values through Excel VBA](https://geekexcel.com/how-to-extract-the-missing-values-through-excel-vba/)**
- **[Excel Formulas to Find the Missing Values From a list!!](https://geekexcel.com/excel-formulas-find-missing-values-from-a-list/)**
- **[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/)**