Hi,
I need help to write a macro that, upon press of a button, the date in a specific cell updates to today's date and then the file is saved and closed.
Thanks
Hi,
I need help to write a macro that, upon press of a button, the date in a specific cell updates to today's date and then the file is saved and closed.
Thanks
Insert something like this into your button code:
[VBA]sub addtime
Range("A1").Select 'where A1 is your "specific cell"
Selection=NOW()
End sub[/VBA]
Try the following code.
You need to add the button, go to "Design Mode" on the VBA toolbar.
Then right click the button and go to "View Code" and insert the routine below, without the sub, End Sub commands.
[vba]
Option Explicit
Sub InsertDate_Close_and_Save_Activeworkbook()
'The following Sheet reference will need to be changed to suit
ActiveWorkbook.Sheets(1).Range("A1").Value = Format(Now, "d/mm/yyyy h:mm") '<= Change format of Time Stamp to suit
' This will close and save the Activeworkbook
ActiveWorkbook.Close savechanges:=True
End Sub
[/vba]
regards,