View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default deselect row/column from multiple selection

And a couple more from Chip Pearson.

Sub UnSelectActiveCell()
Dim rng As Range
Dim FullRange As Range
'Chip Pearson
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()
'Chip Pearson
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


Gord Dibben MS Excel MVP

On Thu, 5 Mar 2009 06:30:01 -0800, Gary''s Student
wrote:

Try this macro:

Sub DropARow()
Set r1 = Selection
n = Application.InputBox(prompt:="enter row# to be de-selected", Type:=1)
Set r2 = Range(n & ":" & n)
Set r3 = Nothing
For Each rr In r1
If Intersect(rr, r2) Is Nothing Then
If r3 Is Nothing Then
Set r3 = rr
Else
Set r3 = Union(r3, rr)
End If
End If
Next
r3.Select
End Sub