Macro to save concatenate names

Tigrou25

New Member
Joined
Nov 22, 2018
Messages
14
Hi all,

I have created a macro to extract few tabs from a spreadsheet and save a new spreadsheet.

I would like to save the new file using the month in the tab "Control_Page" (in cell B12).

I have tried the code below
ActiveWorkbook.SaveAs Filename:= _
"1. " & sheets("Control_Page".Range("B12")&" Monthly P&L Review.xlsx"
which doesn't work.

The idea would be to have the following file name
1. Oct 18 Monthly P&L Review.xlsx
with Oct18 being cell B12 in the tab "Control_Page"

Thanks for your help
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
your missing a Bracket at the end of Sheets...
Code:
ActiveWorkbook.SaveAs Filename:="1. " & sheets("Control_Page"[color=red])[/color].Range("B12")&" Monthly P&L Review.xlsx"
 
Upvote 0
Thanks but it comes with a runtime error 2147352565.

Here is the complete code
ChDir _"S:\Construction\National - Head Office\A Profit and Loss\A01 FY Budgets\08. FY19 P&L\1.Monthly P&L Review"
ActiveWorkbook.SaveAs Filename:= _
"1. " & Sheets("Control_Page").Range("B12") & " Monthly P&L Review.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
 
Upvote 0
Remove the underscore from
Code:
ChDir _"S:
 
Upvote 0
So, one of sheets names is either incorrect or doesn't exist.
Check for leading trailling spaces or maybe that underscore in Control_Page
 
Upvote 0
I have the following error message

rtdxs0.png
 
Upvote 0
Ok, so either
1. you dn't have access to the database on S;\ drive
2. the Drive you are accessing doesn't exist
3. The data source may be locked or protected

But I think you will have to resolve the issue at the Dbase or file location as I don't think it's a VBA issue
 
Upvote 0
That's weird because I can save the file with a standard name but I get this message when I try to save it with the data from the Control_Page tab
 
Upvote 0
OK, try adding value to the string
AND
What is actually in B12 on the control page ?

Code:
ChDir _"S:\Construction\National - Head Office\A Profit and Loss\A01 FY Budgets\08. FY19 P&L\1.Monthly P&L Review"
ActiveWorkbook.SaveAs Filename:= _
"1. " & Sheets("Control_Page").Range("B12") [color=red].value[/color] & " Monthly P&L Review.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,543
Members
449,089
Latest member
davidcom

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