Excel Tool

Order Online
Our company contact information There you can find frequently asked questions and answers

Home | Products |Purchase | FAQ | Contact Us | Useful Resources

Automatically Enter (Insert) the Current Date in Excel (Cells)

Date is a very important piece of information in the record. In order to alleviate the burden of input, we sometimes want Excel to automatically enter (insert) the current date in cells.

Automatically Enter (Insert) the Current Date in Excel

VBA is easy, Right click on the sheet tab, select the "view code" and copy and paste the following code at the cursor:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then Target.Offset(0, 2) = Date
End Sub

The middle line is the core code, means: 1th column (column A) input data, the 2nd on the right column (column C) enter (insert) a date.


If your request is "in column B (2nd column) after you enter (insert) the data in column C (B 1th column to the right of the column) to automatically enter a date", the middle line of code should be replaced with:
If Target.Column = 2 Then Target.Offset(0, 1) = Date

Automatically Enter (Insert) the Current Date in Excel


If you asked "column C (4rd column) of input (insert) data, the column A (C to the left of column 2 columns) automatically enters the date" line of code instead:
If Target.Column = 3 Then Target.Offset(0, -2) = Date

Automatically Enter (Insert) the Current Date in Excel


If you want to enter (insert) the current time, what should I do?
In your code, Date to the current date, you can eat buffet, convert the Date into something to your taste:


Time: Current time.

If Target.Column = 1 Then Target.Offset(0, 2) = Time


Now: The current date/time.

If Target.Column = 1 Then Target.Offset(0, 2) = Now

Copyright © 2001-2014 Excel-Tool All Rights Reserved.

Copyright Excel-Tool All rights reserved