deselect from a non-contiguous selection?

M

me

Hi, is there a way to deselect a single cell from a non-contiguous
selection? That is, if I hold the Ctrl key and select A2, B3, and C5, is
there a way to deselect B3 from that selection? I thought holding the Ctrl
key would toggle the selection a la a listbox, but it doesn't seem to work
for that or any other key combination I have found. Is there a magic bullet?

Thanks,
Mike
 
P

Paul B

me, see if this code from Chip will help

http://redirx.com/?3dba
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003
 
M

me

Can't get to that site. I prefer just a key combination, but pls post the
code. I can't get to that site.
Thanks,
Mike
 
P

Paul B

me here is the full address,

http://groups.google.com/group/micr...130f42fe0e9/8f3070ba01635091#8f3070ba01635091

here is the code that Chip posted

The first, UnSelectActiveCell removes
the active cell from the selection. The second, UnSelectActiveArea,
removes an entire area from the selection. Attach these procedures
to your right-click menu and you'll be all set.

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


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com [email protected]



And to add it to you right click menu



Put the following in the Workbook_Open
procedure of your personal.xls file.


With Application.CommandBars("Cell").Controls
With .Add(temporary:=True)
.Caption = "Unselect Active Cell"
.OnAction = ThisWorkbook.Name & "!UnSelectActiveCell"
.BeginGroup = True
End With
With .Add(temporary:=True)
.Caption = "Unselect Active Area"
.OnAction = ThisWorkbook.Name & "!UnSelectActiveArea"
End With
End With
 
Top