View Full Version : Command Button Programming In Excel
12-09-2005, 03:47 PM
Anyone know how to program a command button in Excel? Here is what I am trying to do. I need a command button that when clicked will save my current file and append the date to the end. e.g. 'Backup12092005'. I have tried to record a macro and then look at the code and then tried to append '=TODAY()'
but that results in the file being saved as 'Backup=TODAY()' which is not what I desire to happen.
12-09-2005, 07:56 PM
It's because Today() is an excel function and not an Excel VBA function.
Getting dates to save in that format is a little tricky in VBA but it can be done:
Dim Filename As String
Filename = "C:\temp\test" & CStr(DatePart("m", Date)) & CStr(DatePart("d", Date)) & CStr(DatePart("yyyy", Date)) & ".xls"
ActiveWorkbook.SaveAs Filename:= _
Filename, FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
12-09-2005, 08:31 PM
you're the man dbax
Powered by vBulletin® Version 4.1.12 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.