VB Script file save as with date

G

Guest

I have a daily metric where I import the data & run with Excel VB script. I'd
like have the script save this as a certain date value in the filename every
day. I have tried using a cell value, then referring to
ActiveWorkbook.SaveAs Filename:=ActiveCell.Value, however, I need to save it
as \\server\reports\daily_market_status 2005-01-13.xls

I have tried using the =today() date format in a cell and cocatenating with
the active saveas cell value, but I just get the date serial number in the
formula.

Any hints?
Thanks!!
 
T

Tom Ogilvy

Filename:=" \\server\reports\daily_market_status\" &
Format(Date,"yyyy-mm-dd") & .xls


Date is the vba equivalent of Today() in the worksheet.
 
R

Ron de Bruin

Use the format function

Format(ActiveCell.Value, "yy-mm-dd")

like this
" \\server\reports\daily_market_status" & " " & Format(ActiveCell.Value, "yy-mm-dd")
 
T

Tom Ogilvy

Misread what you want the filename to be (and left the quotes off ".xls"),
so here is a modification

Filename:=" \\server\reports\daily_market_status " & _
Format(Date,"yyyy-mm-dd") & ".xls"
 

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

Top