Get time in a cell on mouse click

  • Dear all,


    First I would like to thank to all of you that are going to pay attention to this question.


    I've never made a macro or a script in excel/vba, but currently there's a need of creating such.


    There's annoying task that operators at work do - it consists of entering times for completed tasks during the day in an excel sheet.
    My question is : Is there a way that on mouse click excel to take the current system time in the selected cell?



    Thanks in advance once more.


    Best regards,
    Stoyan

  • Re: Get time in a cell on mouse click


    Maybe something like this in the needed sheet:

    Code
    Option Explicit
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        If Target.Column = 3 Then                       'adjust as required (3=column C)
            'Application.EnableEvents = False           'apply if necessary
            Target = Format(Now, "dd/mm/yyyy hh:mm:ss") 'choose format
            'Target = Format(Now, "dd/mm/yyyy")
            'Target = Format(Now, "hh:mm")
            'Application.EnableEvents = True            'same as above
        End If
    End Sub

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!