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

2019-03-05 08:22发布

I use this VBA:

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

But the value of the cell becomes =NOW(), not the date.

I want to push the button and get 2015-03-13, and when I open the sheet tomorrow, it should still say 2015-03-13.

3条回答
老娘就宠你
2楼-- · 2019-03-05 08:53

Maybe you should consider:

Ctrl+:

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-03-05 08:55

Consider:

ActiveCell.Value=Now
查看更多
男人必须洒脱
4楼-- · 2019-03-05 09:07

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

查看更多
登录 后发表回答