SaveAs with cell as a date

jpettit

Board Regular
Joined
Feb 20, 2002
Messages
57
Sub save_itas3()
fname = Application.GetSaveAsFilename _
(InitialFilename:=Range("a1") & " " & WorksheetFunction.Substitute(Date, "/", "_"), _
FileFilter:="Excel Files (*.xls),*.xls", FilterIndex:=0, Title:="Save As")
If fname <> "False" Then
ActiveWorkbook.SaveAs Filename:=fname
End If
End Sub

Can someone break this down for me? I am looking for something similar, yet simpler.
More along these lines, with the cell A1 containing a date of 2002/02/25:

Public Sub SaveAsA1()
ThisFile = Range("A1").Value
ActiveWorkbook.SaveAs FileName:="C:data" & ThisFile
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
The following may be problemtatic as Excel doesn't like to save files with "/".

ThisFile = Range("A1").Value

Therefore, something like:

thisfile = WorksheetFunction.Substitute(range("a1"), "/", "_")

may be more appropriate, where Excel replaces / with _ with the Substitute function (works the same as the worksheet function (e.g., =subsitute(a1,"/","_"))

Cheers, Nate

P.S. - How about that game yesterday?
This message was edited by NateO on 2002-02-25 09:05
 
Upvote 0

Forum statistics

Threads
1,214,559
Messages
6,120,208
Members
448,951
Latest member
jennlynn

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