Link to home
Start Free TrialLog in
Avatar of Berry Metzger
Berry MetzgerFlag for United States of America

asked on

VBA: Save the active worksheet to a file name to include current year followed by active worksheet tab name

Hello Experts:
The following macro, in Module 1 of a XLSM file, falls short of the goal... to save the active worksheet, sans macros, to a file in the same directory as the active file, with a name that begins with a fixed text "WTS_" followed by current year, "_", tab name of active sheet, ".xls".    

Resultant filename will look similar to:  "WTS_2012_7-8"

Thanks for your help    

Dim sCopyName As String
         sCopyName = "WTS_" & Format(Now, "yyyy") &"_"&{active tab name here}& ".xls"
         ActiveWorkbook.SaveAs Filename:=sCopyName, FileFormat:=xlOpenXMLWorkbook
End Sub
Avatar of StephenJR
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Berry Metzger


You nailed it!
Thanks for the quick response