ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   use part of date in cell for save as name (https://www.excelbanter.com/excel-programming/407553-use-part-date-cell-save-name.html)

Helmut

use part of date in cell for save as name
 
I have date in "A1" = 28/02/2008
I want to save worksheet as:

"c:\ToCav0208m.csv"



Patrick Molloy[_2_]

use part of date in cell for save as name
 

fullfilename = "C:\ToCav" & format$(day(Range("A1")),"00") &
format$(year(Range("A1")),"00")



"Helmut" wrote:

I have date in "A1" = 28/02/2008
I want to save worksheet as:

"c:\ToCav0208m.csv"



[email protected]

use part of date in cell for save as name
 
On 12 Mar, 14:20, Helmut wrote:
I have date in "A1" = 28/02/2008
I want to save worksheet as:

"c:\ToCav0208m.csv"


Dim saveName As String
saveName = "C:\ToCav" & Format(Month(Range("A1").Value), "00") &
Format(Range("A1").Value, "yy") & "m.csv"
ThisWorkbook.SaveAs Filename:= saveName

Above assumes A1 is correctly formatted as a date.

--
Gordon

Dave Peterson

use part of date in cell for save as name
 
Dim WksToSave as worksheet
set wks = activesheet
wks.copy 'to a new workbook

with activesheet
'just overwrite the .csv file, don't give me a warning
application.displayalerts = false
.parent.saveas _
filename:="C:\tocav" & format(.range("a1").value, "mmyy") & "m.csv", _
fileformat:=xlcsv
application.displayalerts = true
.parent.close savechanges:=false
end with

Helmut wrote:

I have date in "A1" = 28/02/2008
I want to save worksheet as:

"c:\ToCav0208m.csv"


--

Dave Peterson

Dave Peterson

use part of date in cell for save as name
 
Typo:
Dim WksToSave as worksheet
should be
Dim Wks as worksheet

(or change those wks to wkstosave)

Dave Peterson wrote:

Dim WksToSave as worksheet
set wks = activesheet
wks.copy 'to a new workbook

with activesheet
'just overwrite the .csv file, don't give me a warning
application.displayalerts = false
.parent.saveas _
filename:="C:\tocav" & format(.range("a1").value, "mmyy") & "m.csv", _
fileformat:=xlcsv
application.displayalerts = true
.parent.close savechanges:=false
end with

Helmut wrote:

I have date in "A1" = 28/02/2008
I want to save worksheet as:

"c:\ToCav0208m.csv"


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 07:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com