Insert today's date with button, as date, not function?

前端 未结 3 2028
被撕碎了的回忆
被撕碎了的回忆 2021-01-26 02:16

I use this VBA:

ActiveCell.FormulaR1C1 = \"=NOW()\"
ActiveCell.Offset(1, 0).Range(\"A1\").Select

But the value of the cell becomes =NOW()

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 02:54

    Your code ActiveCell.FormulaR1C1 = "=NOW()" is absolutely perfect. It works correctly on my System. You not need to till tomorrow to check the output of this code, first write this code and run macro and save and close it (please check the date). After closing the file change your system date i.e suppose today is 13-Mar then set the 14-Mar date of your system timing then open the file , you will observer the date in is change. you can write this Thisworkbook in open workbook event.

    Private Sub Workbook_Open() ActiveCell.FormulaR1C1 = "=NOW()" End Sub

    Private Sub Workbook_Open() ActiveCell.Value = Now End Sub

提交回复
热议问题