Thread: excel help
View Single Post
  #8   Report Post  
Gord Dibben
 
Posts: n/a
Default

Rick

Try this version

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'when entering data in a cell in Col A
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" Then
Excel.Range("B" & n).Value = Now
End If
End If
enditall:
Application.EnableEvents = True
End Sub

Or this version to keep previously stamped dates if editing column A

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
'Col B time will not change if data in Col A is edited
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
n = Target.Row
If Excel.Range("A" & n).Value < "" _
And Excel.Range("B" & n).Value = "" Then
Excel.Range("B" & n).Value = Format(Now, "hh:mm:ss")
End If
End If
enditall:
Application.EnableEvents = True
End Sub


Gord Dibben Excel MVP

On 5 Apr 2005 11:17:11 -0700, wrote:

Duke and Julie, I tried the VBA code and have it working. The only
problem is I do not have to enter any data in column A to get the date
in column B. All I need to do is position the curser on a cell in
column A and the date is input. What the problem is, if I move the
curser up to previously input cells, it changes the date. Is there a
way to have this work where you have to have data in each of the
respective column A cells?

Rick