Save WorkSheet as per Cell VALUE (keep original open, and do not open new)

TTUK

Board Regular
Joined
Apr 5, 2012
Messages
137
Hello all,

I am trying to achieve the following within VBA.

1. Save specific worksheet (IIR_temp) to a location shown in the cell in A1 on that page, which is a reference from another sheet =IIR_data!5 which looks like (\\server\report\test.xls)
2. Then have the sheet just be saved, and not to override the current spreadsheet which is open


At present this is what I have:

ActiveSheet.Copy ' Copies active sheet to a new workbook
ActiveSheet.SaveAs Range("A1").Value, xlOpenXMLWorkbookMacroEnabled


I just don't know how to get the formula to save the certain sheet in the specified location shown in A1, and allow me to return as I was in the original spreadsheet.

Hope someone can help me out on this.

Thank you!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
If you want an xls file try
Code:
ActiveSheet.Copy ' Copies active sheet to a new workbook
ActiveWorkbook.SaveAs Range("A1").Value, 56
ActiveWorkbook.Close
 
Upvote 0
Hello Fluff,

I have tried your code.
It create a new worksheet, however, it does not close automatically.
Also it there I can get this new workbook to save as per the name in cell B1?

Thank you
 
Upvote 0
When it created the new workbook, was that new workbook the active workbook?
To use cell B1 as the name just change A1 to B1
 
Upvote 0
When it created the new workbook, was that new workbook the active workbook?
To use cell B1 as the name just change A1 to B1

Hello Fluff,

Yes the new workbook was the active workbook.
I need the new workbook saved in the specific file location of A1
With the specific file name of B1.

Regards, Charlie
 
Upvote 0
In that case use
Code:
ActiveSheet.Copy ' Copies active sheet to a new workbook
ActiveWorkbook.SaveAs Range("A1").Value & Range("B1").value, 56
ActiveWorkbook.Close
You'll need to make sure that the value of A1 ends with a \ or this won't work
 
Upvote 0
Hi Fluff,

Sadly the spreadsheet is not changing it's file name to suite nor is it saving it in the specific location.
I have ensured that a \ is added.

Thanks,
 
Upvote 0
Do you get any error messages?
 
Upvote 0
Hello Fluff,

No I do not get any error message.
It creates the new file and has it as the active sheet, however the file name of the document isn't at the top and it is just showing 'Book 11' for example.
And it isn't saving the file nor closing afterwards either.

Thank you,
 
Upvote 0
What are the values in A1 & B1 on the new workbook?
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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