Deselect Cells from Selected Range using Macros (VBA) in Excel 365!!
Tags: deselectcellsfromase, vbamacros, macrosvba
Published: 2021-02-25 11:25:07

---
title: Deselect Cells from Selected Range using Macros (VBA) in Excel 365!!
published: true
date: 2021-02-25 10:08:04 UTC
tags: Deselectcellsfromase,VBAMacros,MacrosVBA
canonical_url: https://geekexcel.com/deselect-cells-from-selected-range-using-macros-vba-in-excel-365/
---

Generally, we can [deselect the cells from the selection range](https://geekexcel.com/how-to-select-deselect-and-reverse-multiple-ranges-in-excel-365/) using the **CTRL-key.** If you want to do this with a single click, then this article might be helpful to you. Because we come up with the clear-cut steps to **deselect cells from selected range using Macros (VBA)** in Excel Office 365. Let’s get into this article!!
## Deselect Cells from Selected Range:

For deselecting one or multiple cells in the range, do as follows.

- For example, you can see the input values in the Excel worksheet from the given image.

![Input data](https://geekexcel.com/wp-content/uploads/2021/02/1-1.png)<figcaption id="caption-attachment-22137">Input data</figcaption>

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

![Select Visual Basic option](https://geekexcel.com/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 deselect cells using Macros

Sub DeSelectCells()

Set myRange = Application.Selection

Set myRange = Application.InputBox(“Select one Range:”, “DeSelectCells”, myRange.Address, Type:=8)

Set DeleteRng = Application.InputBox(“select one cell or range of cells that you want to deselect”, “DeSelectCells”, Type:=8)

Dim LastRange As Range

For Each myCell In myRange

If Application.Intersect(myCell, DeleteRng) Is Nothing Then

If LastRange Is Nothing Then

Set LastRange = myCell

Else

Set LastRange = Application.Union(LastRange, myCell)

End If

End If

Next

LastRange.Select

End Sub

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

![Save the code](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_k8NcnkGbWi.png)<figcaption id="caption-attachment-22138">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://geekexcel.com/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://geekexcel.com/wp-content/uploads/2021/02/EXCEL_kKyh2BiJmI.png)<figcaption id="caption-attachment-22139">Click the Run button</figcaption>

- Then you need to **select the one range** where you want to deselect cells.
- You have to **click** the **OK** button.

![Select the range](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_s7Fn9vc9QW.png)<figcaption id="caption-attachment-22140">Select the range</figcaption>

- Now, you need to **select one cell or multiple cells** that you want to deselect.
- Then, hit the **OK** button.

![Click the OK button](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_yKyDfOhQKd.png)<figcaption id="caption-attachment-22141">Click the OK button</figcaption>

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

![Deselected cells](https://geekexcel.com/wp-content/uploads/2021/02/EXCEL_KFqqoCdmRf.png)<figcaption id="caption-attachment-22142">Deselected cells</figcaption>

## A Short Summary:

In the above article, you can easily learn how to **deselect cells from a selected range using Macros (VBA)** in Excel Office 365 with clear-cut steps. Kindly, drop your **feedback** in the below comment section. Thanks for visiting **[Geek Excel.](https://geekexcel.com/)** Keep Learning!

### Keep Reading:

- [Create Folders Based on Cell Values using Macros (VBA) in Excel 365!!](https://geekexcel.com/create-folders-based-on-cell-values-using-macros-vba-in-excel-365/)
- [How to Copy a Cell to Clipboard using Macros (VBA) in Excel 365?](https://geekexcel.com/how-to-copy-a-cell-to-clipboard-using-macros-vba-in-excel-365/)
- [Add a Degree Symbol to Selection Range using Macros (VBA) in Excel!](https://geekexcel.com/add-a-degree-symbol-to-selection-range-using-macros-vba-in-excel/)