Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Offset problem in Time Stamp Code

Status
Not open for further replies.

Randy11

Technical User
Oct 4, 2002
175
CA
2 Issues:
1) Am having trouble altering the column the time stamp is going in with the code below. Instead of result landing in Column B, would like column D. When I change the 2nd offset digit to 3 instead of 1 there is no change?
2) Would also like to have a 2 - 4 of these same activities occur for data entered into different ranges in the same worksheet. Have attempted to copy this & alter it to deal with the other ranges with no success. Assitance & Ideas appreciated.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A2:A10"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Offset(0, 1).ClearContents
Else
With .Offset(0, 1)
.NumberFormat = "dd mmm yyyy hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub
 


hi,
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    With Target
        If .Count > 1 Then Exit Sub
        If Not Intersect(Range("A2:A10"), .Cells) Is Nothing Then
            Application.EnableEvents = False
            If IsEmpty(.Value) Then
            '[b][highlight]Instead of result landing in Column B, would like column D[/highlight][/b]
                Cells(.Row, "D").ClearContents
            Else
            '[b][highlight]Instead of result landing in Column B, would like column D[/highlight][/b]
                With Cells(.Row, "D")
                    .NumberFormat = "dd mmm yyyy hh:mm:ss"
                    .Value = Now
                End With
            End If
            Application.EnableEvents = True
        End If
    End With
End Sub

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thank you, this worked. Am now stuck with another issue. Am trying to apply two worksheet change codes to same work sheet & will only run one?
Am I missing a separator or code between the two?
 



Please post your new question in an new thread, along with the code you referred to, but failed to post.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top