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

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
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,223,315
Messages
6,171,410
Members
452,399
Latest member
oranges

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