|
|
#1 |
|
Ensign
|
Command Button Programming In Excel
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. |
|
|
|
|
|
#2 |
|
Rear Admiral Lower Half
![]() ![]() |
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:= _ False, CreateBackup:=False End Sub |
|
|
|
|
|
#3 |
|
Old Skooler Numba 1
![]() ![]() |
you're the man dbax
__________________
~~~~~~~~~~~~ 3 days ~ Willie Nelson 3 days I dread to see arrive 3 days I hate to be alive 3 days filled with tears and sorrow yesterday today and tomorrow |
|
|
|