Highlight Cells with a Single Space using Macros (VBA) in Excel!!
Tags: highlightcellswithas, vbamacros
Published: 2021-02-17 11:31:35

---
title: Highlight Cells with a Single Space using Macros (VBA) in Excel!!
published: true
date: 2021-02-17 08:44:03 UTC
tags: Highlightcellswithas,VBAMacros
canonical_url: https://geekexcel.com/highlight-cells-with-a-single-space-using-macros-vba-in-excel/
---

If you go throwing some important data in the Excel spreadsheet and there are a lot of single spaces, what will you do to find that? You can use Macros to find cells with a single space quickly. In this article, we are going to see the steps to **highlight cells with a single space using Macros ([VBA](https://geekexcel.com/excel-office-365-vba-overview-definition-and-examples/))** in **Excel Office 365**.
## Highlight Cells with a Single Space:

You need to follow the below steps to find cells with a single space.

- In the below image, you can see the set of input values in the range **B1:B10** , and also there are some single spaces.
- We are going to highlight them with the help of Macros.

![Input range](https://eadn-wc04-371788.nxedge.io/cdn/wp-content/uploads/2021/02/1.png)<figcaption id="caption-attachment-21971">Input range</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 single spaces using Macros

Sub HighlightSingleSpaces()

Dim range As Range

For Each range In ActiveSheet.UsedRange

If range.Value = ” ” Then

range.Style = “Note”

End If

Next range

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_VTo34vPpQP.png)<figcaption id="caption-attachment-21972">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_jvfDXv9SzV.png)<figcaption id="caption-attachment-21973">Click the Run button</figcaption>

- At last, you will see the highlighted single spaces as shown in the below image.

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

## Summary:

In the above article, you can easily understand the steps to **highlight cells with a single space using Macros (VBA)** in Excel Office 365. Feel free to share your **suggestions/feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

#### Related Articles:

- [Remove Extra Spaces from Selection Using Macros (VBA) in Excel!!](https://geekexcel.com/remove-extra-spaces-from-selection-using-macros-vba-in-excel/)
- [Highlight Max Value in Selection using Macros (VBA) in Excel 365!!](https://geekexcel.com/highlight-max-value-in-selection-using-macros-vba-in-excel-365/)
- [Resize All Charts using Macros (VBA) in Excel Office 365!!](https://geekexcel.com/resize-all-charts-using-macros-vba-in-excel-office-365/)