Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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" wrote in message ... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy sheets into one book | Excel Worksheet Functions | |||
copy worksheets to new book without linking to original book | Excel Discussion (Misc queries) | |||
Copy selected sheets to new book | Excel Programming | |||
copy the same raws of all sheets from about a 100 file to a new sheet of a book and save the file | Setting up and Configuration of Excel | |||
Create New Workbook - Name book - 4 Sheets - Name Sheets | Excel Programming |