Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of Berry Metzger
Berry MetzgerFlag for United States of America asked on
Microsoft Excel
2 Comments1 Solution640 ViewsLast Modified:
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"
         ActiveSheet.Copy
         ActiveWorkbook.SaveAs Filename:=sCopyName, FileFormat:=xlOpenXMLWorkbook
         ActiveWindow.Close
End Sub
ASKER CERTIFIED SOLUTION
Avatar of StephenJR
StephenJRFlag of United Kingdom of Great Britain and Northern Ireland image

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers