use part of date in cell for save as name

  • Thread starter Thread starter Helmut
  • Start date Start date
H

Helmut

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

"c:\ToCav0208m.csv"
 
fullfilename = "C:\ToCav" & format$(day(Range("A1")),"00") &
format$(year(Range("A1")),"00")
 
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.
 
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
 
Typo:
Dim WksToSave as worksheet
should be
Dim Wks as worksheet

(or change those wks to wkstosave)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top