Share via

Auto fill Date and Time

Anonymous
2021-06-25T18:13:01+00:00

I would like excel to auto fill the date and time whenever an entry is entered into my spreadsheet. Preferably into different cells (one for date and one for time). This date cannot change every time the worksheet is recalculated like the Today or Now function does.

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

8 answers

Sort by: Most helpful
  1. Anonymous
    2021-06-28T10:44:53+00:00

    Looking for Current date and time.  What we have is an inspection sign in log.  Whenever someone from production needs an item inspected, they enter the info into this spreadsheet.  We track how long it takes inspection to return the time back to production.  I am trying to make this as easy and mistake free as possible for production by eliminating as much typing as I can.  The operator is to scan their employee badge when they go to sign in a part to be inspected. When this happens, I want the spreadsheet to auto fill the date and time.  This date and time needs to be static.  Then the operator can continue to scan the rest of the needed information.

    Date In Time In
    05/31/21 23:18
    05/31/21 23:37
    05/31/21 23:37
    05/31/21 23:56
    05/31/21 23:58
    05/31/21 23:59
    06/01/21 0:18
    06/01/21 0:27
    06/01/21 0:53
    06/01/21 1:04
    06/01/21 2:00
    06/01/21 2:27
    06/01/21 2:43
    06/01/21 2:49
    06/01/21 3:13
    3 people found this answer helpful.
    0 comments No comments
  2. HansV 462.6K Reputation points MVP Volunteer Moderator
    2021-06-25T18:53:06+00:00

    Let's say you want the date to be entered in cell W1 and the time in cell W2.

    Right-click the sheet tab.

    Select 'View Code' from the context menu.

    Copy the following code into the worksheet module:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    Range("W1").Value = Date
    Range("W2").Value = Time
    Application.EnableEvents = True
    End Sub

    Switch back to Excel.

    Save the workbook as a macro-enabled workbook (*.xlsm).

    Make sure that you allow macros when you open it.

    2 people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2021-07-01T12:37:44+00:00

    I got it. Thanks for all your help. I would have never gotten there without it. Solution shown below.

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("D:D")) Is Nothing Then 
    
        Range("A" & Target.Row).Value = Date 
    
        Range("B" & Target.Row).Value = Time 
    
    End If 
    

    End Sub

    1 person found this answer helpful.
    0 comments No comments
  4. Anonymous
    2021-06-28T18:34:51+00:00

    Your first option is to use a few shortcut keys: Ctrl+; enters the current date, Ctrl+: enters the current time.  These entries are static, they will not change.

    A formula won't work because it can't be both active and static, so another solution is a macro.  Let's suppose there are three columns A:C with the date and time in columns B and C.  You can create a macro that automatically enters the date and time in columns B:C when an entre is made in column A.  Here is a quick example:

    Image

    In this case you would format column B to a date format and column C to a time format.  Anytime a change is made to an entry in column A the macro runs.  This is what's known as an event macro, in this case a Worksheet Change which has been add to the code sheet for the worksheet where the data is to be entered.  Their are some possible issues with this approach but I've tried to make it as simple as possible.

    A fancier version might be something like this:

    In this case columns B and C don't need to be manually formatted.

    1 person found this answer helpful.
    0 comments No comments
  5. Anonymous
    2021-06-25T22:43:00+00:00

    The first question we need to ask is are you auto filling the date or the time or both?  Regardless, what is your time increment, for example every 15 minutes, every hour, every 6 hours.  For that matter what is the date increment.  Please give us an example.  

    1 person found this answer helpful.
    0 comments No comments