Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Naming convention for a variable "Book1" while copying sheets
I have gotten this far in developing a macro for saving
sheets to a new workbook that users will name themselves. I can not count on the new workbook to be "Book1" all the time as the user may have one or more new Books (Book1-n) open and the next book number would be book1-n+1. So I need to somehow establish a convention to assign a name to the new book in the following code (in earlier versions of this saga I was copying only the input cells to a new book and the solution there was to simply use "Windows(2)" as the second book. That doesn't work in this case.) Sub sheetsavetrialz() ' 'This starts the save process which saves all cells with required or optional user input in the selected areas to a new workbook. 'establishes "ps" as the name for the active workbook ps = ThisWorkbook.Name Windows(ps).Activate ActiveWindow.WindowState = xlMinimized Workbooks.Add Windows("ps").Activate Sheets("Environment").Select Sheets("Environment").Copy Befo=Workbooks ("Book1").Sheets(1) Windows("ps").Activate Sheets("CT").Select Sheets("CT").Copy Befo=Workbooks("Book1").Sheets(1) .... and on until the desired sheets (selected via a control) are saved. THANKS! JER |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Stop "Book1" from opening from a saved file | Excel Discussion (Misc queries) | |||
"Type mismatch" when I try to fill an Array variable with "+" | Excel Discussion (Misc queries) | |||
Naming cell ranges, copying formulas for a range & nesting "IF" fu | Excel Discussion (Misc queries) | |||
Why is "History" a "reserved name" while naming Excel worksheets? | Excel Discussion (Misc queries) |