View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default selectin the whole column beside the target cell

not sure what you're trying to do, but give this a try

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngfound As Range
If Target.Count = 1 Then
With Columns(Target.Offset(, 1).Column)
Set rngfound =
..Find(WorksheetFunction.Max(Columns(.Column)), _
lookat:=xlWhole, LookIn:=xlValues)
If Not rngfound Is Nothing Then
Range(rngfound.Address).Value = _
Range(rngfound.Address).Value + 1
End If
End With
End If
End Sub


--

Gary Keramidas
Excel 2003


"NDBC" wrote in message
...
I have the following code which is trying to determine the maximum value in
the whole column beside the target cell, then add 1 to it and enter it in
the
column beside the target cell. It doesn't give an error but it is not
selecting the right values

Target.Offset(0, 1) = WorksheetFunction.Max(Range(Target.Column + 1 & ":"
&
Target.Column + 1)) + 1

Thanks