View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default select one of 6 cells down in column

Phillip Swanepoel wrote:

i have a column where they need to select just one cell at a time. if
for example E9 has a x then this but if user select E11 this and then E9
must be deselected automatically...

and perhaps any way to 'clean up' or make use of this easier for the end
user?


If you only want the user to select a single cell at a time, anywhere on the
sheet, you can do this in the sheet's object:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Cells.Count 1 Then ActiveCell.Select
End Sub

Alternately, you can specifically check for cells in column E in the
selection:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim cel As Range, addr As String
If Not (Application.Intersect(Target, Range("E:E")) Is Nothing) Then
For Each cel In Target
If cel.Column = 5 Then '5-column E
'Here is where you decide if the cell remains in the selection.
If cel.Value = "x" Then addr = addr & "," & cel.Address
Else
addr = addr & "," & cel.Address
End If
Next
If Len(addr) 0 Then Range(Mid$(addr, 2)).Select
End If
End Sub

....but note that this will lead to some rather unexpected behavior (related
to selecting individual cells, instead of groups).

--
If only the good die young, what does that say about senior citizens?