ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Export Several Worksheet Groups (Values Only) Macro (https://www.excelbanter.com/excel-programming/442695-export-several-worksheet-groups-values-only-macro.html)

Louise

Export Several Worksheet Groups (Values Only) Macro
 
Hi All,

I need some help please...

I have a workbook (which due to many pivots and formulae is massive), I need
a macro to export groups of sheets to new workbooks (each time it is run)
then return to the workbook and export another group for example:

I need Belgium & Netherlands to be exported (values only) to one workbook,
then from the original workbook I need Spain & Switzerland exported to
another fresh workbook, so in the end I have 3 files, one original, one with
Bel & Neth, and the other with Spa & Swi. I also need the data to be exported
as values only.

Currently I have the code below but it errors on workbook("Test").Select

Sheets(Array("Netherland", "Belgium")).Select
ActiveWindow.SelectedSheets.Copy

Workbook("Test").Select

Any help much appreciated

Jacob Skaria

Export Several Worksheet Groups (Values Only) Macro
 
I didnt get what workbook "Test" is? If you want to select or save the new
workbook try the below....

Dim wb As Workbook
Sheets(Array("Netherland", "Belgium")).Copy
Set wb = ActiveWorkbook
wb.SaveAs "c:\test.xls"


--
Jacob (MVP - Excel)


"Louise" wrote:

Hi All,

I need some help please...

I have a workbook (which due to many pivots and formulae is massive), I need
a macro to export groups of sheets to new workbooks (each time it is run)
then return to the workbook and export another group for example:

I need Belgium & Netherlands to be exported (values only) to one workbook,
then from the original workbook I need Spain & Switzerland exported to
another fresh workbook, so in the end I have 3 files, one original, one with
Bel & Neth, and the other with Spa & Swi. I also need the data to be exported
as values only.

Currently I have the code below but it errors on workbook("Test").Select

Sheets(Array("Netherland", "Belgium")).Select
ActiveWindow.SelectedSheets.Copy

Workbook("Test").Select

Any help much appreciated


Louise

Export Several Worksheet Groups (Values Only) Macro
 
Hi Jacob - Thank you for responding, "Test" is my original workbook, I
presume after 'exporting' the 2 sheets Netherlands and Belgium, my macro
would then have to reselect / make active the main/original workbook to then
export the next 2 grouped sheets Spain & Switzerland?

Thanks for your help!

"Jacob Skaria" wrote:

I didnt get what workbook "Test" is? If you want to select or save the new
workbook try the below....

Dim wb As Workbook
Sheets(Array("Netherland", "Belgium")).Copy
Set wb = ActiveWorkbook
wb.SaveAs "c:\test.xls"


--
Jacob (MVP - Excel)


"Louise" wrote:

Hi All,

I need some help please...

I have a workbook (which due to many pivots and formulae is massive), I need
a macro to export groups of sheets to new workbooks (each time it is run)
then return to the workbook and export another group for example:

I need Belgium & Netherlands to be exported (values only) to one workbook,
then from the original workbook I need Spain & Switzerland exported to
another fresh workbook, so in the end I have 3 files, one original, one with
Bel & Neth, and the other with Spa & Swi. I also need the data to be exported
as values only.

Currently I have the code below but it errors on workbook("Test").Select

Sheets(Array("Netherland", "Belgium")).Select
ActiveWindow.SelectedSheets.Copy

Workbook("Test").Select

Any help much appreciated



All times are GMT +1. The time now is 06:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com