View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
PYO1012 PYO1012 is offline
external usenet poster
 
Posts: 6
Default Date Stamp in one cell when data in other range changes

Thank you, Dave, for responding! I tried exactly what you suggested
"..Offset(0, -2).value = "" " and that worked perfectly. Thank you, again!!

"Dave Peterson" wrote:

First, the code doesn't run when you start to change the cell--it fires when you
finish (hitting enter or tab or selecting another cell).

Which line causes the error?

Please share the exact details--addresses, values in the cells that are changing
and your keystrokes of what you're doing.

The only thing that I see that could be causing trouble is this line:

..Offset(0, -2).ClearContents

This will fail if that .offset(0,-2) cell is part of a merged set of cells.

If you're using merged cells, change this line to:

..Offset(0, -2).value = ""



PYO1012 wrote:

I have a question:

I've been using Dave's macro for a while now but there's one thing I wish I
could resolve...
The problem is a Debug error that occurs when I start to type in the cell
that triggers the timestamp but then decide to delete what I was typing and
leave the cell with no information. Is there something that can be added to
the following macro to have it keep the debug error from happening when I
leave the trigger cell blank after clicking in it?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("E11:E510"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, -2).ClearContents
Else
With .Offset(0, -2)
.NumberFormat = "hh:mm"
.Value = Time
End With
End If
Application.EnableEvents = True
End If
End With
End Sub

Any help would be appreciated!


--

Dave Peterson
.