I am trying to automatically update the date and time in an excel sheet as I open it

时间:2015-05-04 19:34:43

标签: excel-vba vba excel

I have a website that needs to update date and time and reference number as I open the excel sheet template. How can I do that? Let's just say a customer is calling to make a reservation and as I open the excel sheet my current date and time and reference fields must be updated automatically. How can I do this. Any help will be appreciated.

2 个答案:

答案 0 :(得分:1)

In the cell just type =NOW(), it will automatically grab the date and time of the instant it is opened.

答案 1 :(得分:0)

There is a function in excel : =Now() that can let you get the current datetime.

or you can do it programmatically inside the workbook

Private Sub Workbook_Open()
 Range("A2").value = now()
'if you want an specific date format use : Format(Now(), "dd/mm/yyyy")
 Range("A3").value = "References"
'etc
End Sub