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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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