Thread: date column
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default date column

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler:
If Target.Count 1 Then Exit Sub
If Not Intersect(Range("K2:K30"),Target) is nothing Then
Application.EnableEvents = False
Cells(Target.Row, 11).Value = Now
Cells(Target.Row, 11).NumberFormat = "mm/dd/yy hh:mm"
Columns(11).AutoFit
End If
ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


jamie85 wrote in message
...
Great thanks i have edited the code to suit as follows:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrHandler:
If Target.Count 1 Then Exit Sub
If Target.Column < 11 Then
Application.EnableEvents = False
Cells(Target.Row, 11).Value = Now
Cells(Target.Row, 11).NumberFormat = "mm/dd/yy hh:mm"
Columns(11).AutoFit
End If
ErrHandler:
Application.EnableEvents = True
End Sub

What would i have to change so the code would only apply to cells K2 -
K30 ? Thanks


---
Message posted from http://www.ExcelForum.com/