save as copy the active work book based on active sheet name add some other contains

nkashyap3

New Member
Joined
Jun 27, 2019
Messages
24
Office Version
  1. 2010
Platform
  1. Windows
Hi am not able the add some contains if i save as the active workbook .
I want to save as the excel file based on tab name with add additional contains in mid

if my active tab name is ML51HJ0 MTD Aug(tab name not fixed it will change)

my query is save as the file name ML51HJ0_AcntAnalysis MTD Aug Actuals

I have many file which i need same thing. (_AcntAnalysis) and (Actuals) will add in all excel file.

Sub save_003()
MName = ActiveSheet.Name & "Actuals" & ".xlsx"
MDir = ActiveWorkbook.path
ActiveWorkbook.SaveCopyAs Filename:=MDir & "" & MName
End Sub

please help to rectify this .
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this:

Code:
Sub save_003()
  Dim MName As String, MDir As String
  MName = WorksheetFunction.Substitute(ActiveSheet.Name, " ", "_AcntAnalysis ", 1) & " Actuals" & ".xlsx"
  MDir = ActiveWorkbook.Path
  ActiveWorkbook.SaveCopyAs Filename:=MDir & "\" & MName
End Sub
 
Upvote 0
Thanks a lot Dante, great work and code if perfectly working according to my requirement. you always accurate answer
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top