copying of a sheet to a new workbook

ashleywanless

Board Regular
Joined
Aug 4, 2009
Messages
158
I have some code which i use to export a sheet to a new workbook, its a summary reporting sheet. It works fine but im wondering if i can improve this.

At the moment the issue is the code has to reference the new workbook to copy the data (fields have more than 255 characters). Excel adds 1 to each new workbook that opens so i can only copy the sheet once before i get a debug as the second time the new worksheet is in Book2.

Is it possible to get around this by restructuring the code to not reference the new book? I'm thinking this could be done by using the string function to refer to the book as a variable? Any help would be great.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Whoops

Code is

Sheets("Export Report").Select
Sheets("Export Report").Copy
Windows("Open Cases.xls").Activate
Cells.Select
Range("A1").Activate
Selection.Copy
Windows.("Book1").Activate
Cells.Select
Range("A1").Activate
ActiveSheet.Paste
Sheets("Export Report").Select
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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