Highlight & Count a Specified Value using Macros in Excel 365!!
Tags: highlightcountaspeci, vbamacros
Published: 2021-02-18 11:43:28

---
title: Highlight & Count a Specified Value using Macros in Excel 365!!
published: true
date: 2021-02-18 09:44:56 UTC
tags: Highlightcountaspeci,VBAMacros
canonical_url: https://geekexcel.com/highlight-count-a-specified-value-using-macros-in-excel-365/
---

If you want to know how many times a specific value entered into the worksheet, what would you do? In this article, we are going to see how to **highlight & count a specified value using Macros ([VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/)) in Excel Office 365**. You just follow the instructions given below and complete your work quickly.
## Highlight & Count a Specified Value using Macros:

To highlight and find the cells with the specified value, follow the below instructions.

- For example, you can see the range of data **B1:B8** in the following image. We are going to find the specific value from the range.

![Example data](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_w3Kwd4upxq.png)<figcaption id="caption-attachment-21997">Example data</figcaption>

- On the **Developer Tab, select** the **Visual Basic** option under the **Code** section.

![Select Visual Basic option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Select-Visual-Basic-option-4.png)<figcaption id="caption-attachment-14755">Select the Visual Basic option</figcaption>

- Then you need to copy and paste the code given below.

VBA code to highlight and count the specific value using Macros

Sub HighlightAndCountSpecifiedValue()

Dim cell As Range

Dim counter As Integer

Dim specificValue As Variant

specificValue = InputBox(“Enter Value To Highlight”, “Enter Value”)

For Each cell In ActiveSheet.UsedRange

If cell = specificValue Then

cell.Style = “Note”

counter = counter + 1

End If

Next cell

MsgBox “There are a total of ” & counter &” “& specificValue & ” in this worksheet.”

End Sub

- You need to **save the code** by selecting it. Then **close** the **window.**

![Save the code](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_4xGiS5oGTn.png)<figcaption id="caption-attachment-21998">Save the code</figcaption>

- You have to open the sheet containing the data. On the **Developer Tab, choose** the **Macros option** in the **Code** section.

![Choose the Macros option](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2020/09/Choose-the-Macros-option-2.png)<figcaption id="caption-attachment-14747">Choose the Macros option</figcaption>

- You need to make sure that your macro is selected and **click** the **Run** button.

![Click the Run button](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_KdqG7BYowN.png)<figcaption id="caption-attachment-21999">Click the Run button</figcaption>

- Then it will display **Enter the value dialog box**. You need to **enter the value** that you want to highlight and count in the selection.

![Click OK button](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_kC6apR3DqV.png)<figcaption id="caption-attachment-22000">Click OK button</figcaption>

- Now, you will get the result as shown in the below image.

![Output](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/EXCEL_qdHOsePhCL.png)<figcaption id="caption-attachment-22001">Output</figcaption>

## Sum-Up:

In this article, you can easily learn the clear-cut steps o **highlight & count a specified value using Macros in Excel Office 365**. Kindly, give your **feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

#### Keep Reading:

- [Highlight Cells with a Single Space using Macros (VBA) in Excel!!](https://geekexcel.com/highlight-cells-with-a-single-space-using-macros-vba-in-excel/)
- [Convert Formulas into Values using Macros (VBA) in Excel 365!!](https://geekexcel.com/convert-formulas-into-values-using-macros-vba-in-excel-365/)