Unselecting A Cell Or Area 

 

As you know, you can select non-contiguous ranges of cells using the CTRL key.  For example, you can hold down the CTRL key and click on A1, A3, A5, and A7.  This will select only those cells, so you can, for instance, apply bold font to those cells.   

UnSelecting A Single Cell

However, once a cell has been selected, Excel does not allow you remove that cell from the selected cell without unselecting all the cells in the selection.  For example, suppose you want to select A1, A3, A5, and A7, but inadvertently select A4 instead of A5.  The procedure below will allow you to remove A4 from the selection, will keeping all the other cells.  

To use the procedure, keep all your original cells selected, and with the CTRL key still down, make A4 (or whatever cell you want to remove) the ActiveCell.  To do this, just keep the CTRL key down and select that cell.  Then run the macro UnSelectActiveCell.  This will leave all the cells other than the ActiveCell selected.  Now, hold the CTRL key down and continue selecting cells.   

Sub UnSelectActiveCell()
Dim Rng As Range
Dim FullRange As Range

If Selection.Cells.Count > 1 Then
    For Each Rng In Selection.Cells
        If Rng.Address <> ActiveCell.Address Then
            If FullRange Is Nothing Then
                Set FullRange = Rng
            Else
                Set FullRange = Application.Union(FullRange, Rng)
            End If
        End If
    Next Rng

    If FullRange.Cells.Count > 0 Then
        FullRange.Select
    End If
End If

End Sub


This procedure unselects a single cell.  To unselect an Area, see below.

UnSelecting An Area

You can use a similar procedure to unselect an entire area.  An area is a rectangular region of cells.  A simple selection like A1:C5 is a single area, since it is a simple rectangle.  However, a selection like A1:C5,D1:E3 is two areas (A1:C5 and D1:E3).  A non-contiguous select may contain any number of areas.   To remove an area from a selection, put the ActiveCell in any cell in the area you want to unselect, and run the macro UnSelectActiveArea.   This will leave all the cells other than the area containing the ActiveCell selected.  Now, hold the CTRL key down and continue selecting cells.   

Sub UnSelectActiveArea()

Dim Rng As Range
Dim FullRange As Range
Dim Ndx As Integer
If Selection.Areas.Count > 1 Then
    For Each Rng In Selection.Areas
        If Application.Intersect(ActiveCell, Rng) Is Nothing Then
            If FullRange Is Nothing Then
                Set FullRange = Rng
            Else
                Set FullRange = Application.Union(FullRange, Rng)
            End If
        End If
    Next Rng
    FullRange.Select
End If

End Sub