Arul Servin
Arul Servin

Reputation: 43

Make file name containing date (VBA)

I want to save a file in a directory, and the filename should have this format:

iTerm Metrics Report Apr 12

i.e. the root file name "iTerm Metrics Report", followed by today's date formatted as three-letter month followed by day of the month.

How do I make such a filename?

Upvotes: 1

Views: 9272

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149295

sFile = "iTerm metrics Report" & "" & Format(Date) & ".xls" ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\706849\My Documents\Metric Report\" & sFile – Arul Servin 5 secs ago

Is this what you are trying?

sFile = "iTerm metrics Report " & Format(Date,"mmm yy") & ".xls"

FOLLOWUP

Thank you...but am trying for Date (Apr 12) 12 is a date not a year...Please suggest me accordingly...thanks – Arul Servin 55 secs ago

In that case change the code to

sFile = "iTerm metrics Report " & Format(Date,"mmm dd") & ".xls"

Upvotes: 4

Related Questions