• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

hi, have vba code when i enter a data in cell b2 automatically date and start time comes in cell C3.

shankar ganesh

New Member
Screen Shot 2018-12-20 at 13.32.42.png
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
        With Target
            If .Count > 1 Then Exit Sub
            If Not Intersect(Range("B2:B1048576"), .Cells) Is Nothing Then
                Application.EnableEvents = False
                If IsEmpty(.Value) Then
                    .Offset(0, 1).ClearContents
                Else
                    With .Offset(0, 1)
                        .NumberFormat = "hh:mm:ss"
                        .Value = Now
                    End With
                End If
                Application.EnableEvents = True
            End If
        End With
    End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Columns("D")) Is Nothing Then
    If Target.Value = "" And Target.Offset(0, -1) <> "" Then Target = Time
 
End If
 
End Sub
 

Attachments

  • AHT.xlsm
    159.7 KB · Views: 1
Last edited by a moderator:
Back
Top