Excel Macro VBA to Append to existing file name

Hello

Looking for some Excel VBA, to pre-pend to an existing filename.  The spreadsheet comes to me with the a file name in number format  like
2015010203.xls

the file name changes daily,

so after I make my changes , i want to have excel VBA macro that prepends to the existing file name, "MAC_(then the old filename.xls)
thanks
rsernowskiAsked:
Who is Participating?
 
SimonCommented:
The simplest version - no test for pre-existing file of same name...

Sub PrePendToFilename()
ActiveWorkbook.SaveAs (Replace(ActiveWorkbook.FullName, ActiveWorkbook.Name, "Mac_" & ActiveWorkbook.Name))
End Sub

the simply searches for the name of the replaces the name of the existing workbook within its full path with the new name and saves the file in the same folder as the original but with the new name.
0
 
rsernowskiAuthor Commented:
Hi Simon
Excellent , Thanks for your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.