Enter current date into cell with VBA

babycody

Well-known Member
Joined
Jul 8, 2003
Messages
1,395
Title says it all. I would like for the current date to be entered into a specific cell. The Today() function changes every time a sheet is opened. I want to be able to make a copy of a sheet and keep the date in the cell the same as when the sheet was copied. Thanks for any help.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Modify for cell address and desired format.

Sub Test1()
With Range("A1")
.Value = Date
.NumberFormat = "mm/dd/yy"
End With
End Sub
 
Upvote 0
If you wanted to input it into multiple cells, how would you do it? As in, is there a way to do it without writing out the code multiple times?
 
Upvote 0
Felix, just changing the Range of Tom example's from A1 to A1:B5, for example.

Code:
[COLOR=#333333]Sub Test1()[/COLOR]
[COLOR=#333333]With Range("A1:E5")[/COLOR]
[COLOR=#333333].Value = Date[/COLOR]
[COLOR=#333333].NumberFormat = "mm/dd/yy"[/COLOR]
[COLOR=#333333]End With[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top