PC Review


Reply
Thread Tools Rate Thread

Copy Sheets to new Book

 
 
Steve
Guest
Posts: n/a
 
      26th Mar 2008
Hello. In my workbook I need to copy 2 sheets into a new book. I
have the code below that does just that. Here's the twist - The sheet
named "Customer Number" will vary. But the sheet name will be in Cell
B2 of the worksheet "Check Request". So, can I modify the below code
to copy 2 sheets: Check Request, and the sheet name identified in
Check Request B2? Thanks

Sheets(Array("Check Request", "Customer Number")).Copy
 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      26th Mar 2008
Dim twist As String
twist = Worksheets("Check Request").Range("B2").Value
Sheets(Array("Check Request", twist)).Copy

"Steve" wrote:

> Hello. In my workbook I need to copy 2 sheets into a new book. I
> have the code below that does just that. Here's the twist - The sheet
> named "Customer Number" will vary. But the sheet name will be in Cell
> B2 of the worksheet "Check Request". So, can I modify the below code
> to copy 2 sheets: Check Request, and the sheet name identified in
> Check Request B2? Thanks
>
> Sheets(Array("Check Request", "Customer Number")).Copy
>

 
Reply With Quote
 
Mika Oukka
Guest
Posts: n/a
 
      26th Mar 2008
This ought to work

Dim SheetToCopy As String
SheetToCopy = Sheets("Check Request").Range("B2").Value
Sheets(Array("Check Request", SheetToCopy)).Copy

You can also refer to a worksheet by its order from left to right.

Regards,

Mika Oukka

"Steve" <(E-Mail Removed)> wrote in message
news:495a98d0-cec7-4470-8f2b-(E-Mail Removed)...
> Hello. In my workbook I need to copy 2 sheets into a new book. I
> have the code below that does just that. Here's the twist - The sheet
> named "Customer Number" will vary. But the sheet name will be in Cell
> B2 of the worksheet "Check Request". So, can I modify the below code
> to copy 2 sheets: Check Request, and the sheet name identified in
> Check Request B2? Thanks
>
> Sheets(Array("Check Request", "Customer Number")).Copy



 
Reply With Quote
 
Ron de Bruin
Guest
Posts: n/a
 
      26th Mar 2008
Try this Steve

Sub test()
Dim MySheetString As String

MySheetString = Sheets("Check Request").Range("B2")
Sheets(Array("Check Request", MySheetString)).Copy
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Steve" <(E-Mail Removed)> wrote in message news:495a98d0-cec7-4470-8f2b-(E-Mail Removed)...
> Hello. In my workbook I need to copy 2 sheets into a new book. I
> have the code below that does just that. Here's the twist - The sheet
> named "Customer Number" will vary. But the sheet name will be in Cell
> B2 of the worksheet "Check Request". So, can I modify the below code
> to copy 2 sheets: Check Request, and the sheet name identified in
> Check Request B2? Thanks
>
> Sheets(Array("Check Request", "Customer Number")).Copy

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy cells from 4 w'sheets in multiple w'books to 1 w'sheet in 1 w'book plant007 Microsoft Excel Misc 0 2nd Jun 2011 11:34 AM
Copy sheets into one book Eva Microsoft Excel Worksheet Functions 2 17th Nov 2009 06:43 PM
Copy selected sheets to new book Al Microsoft Excel Programming 1 31st Jan 2008 09:25 PM
copy the same raws of all sheets from about a 100 file to a new sheet of a book and save the file attis555@hotmail.com Microsoft Excel Setup 0 14th Mar 2007 02:13 AM
in VBA Sheets("mysheet").Copy Before:=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Microsoft Excel Worksheet Functions 1 6th Jul 2005 09:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:53 PM.