Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
specifying workbook for Sheet1
There was discussion last week of the advantage of referring to a worksheet
by Sheet1 rather than WorkSheets("mysheet") or WorkSheets(1). My question is how to specify what workbook the sheet is in. Nothing I've tried works. For example I've tried: Workbooks("mybook").Sheet1 Thanks in advance, Doug |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
specifying workbook for Sheet1
Hi Doug,
Since you can call worksheets only from a collection (not directly wit their names), you need to use an object variable or type th collection Try this : Dim xsThisWorksheet as Worksheet Set xsThisWorksheet = Workbooks(WorkbookIndex).Worksheets(SheetIndex) you can have the same result by using workbookname and sheetname. Bu don't forget to put them into ", if you use names -- Message posted from http://www.ExcelForum.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
specifying workbook for Sheet1
Thanks Toltag, but that's not what I meant. I'm talking about the ability
to refer to as simply Sheet1 as in: Sheet1.select If you open a new workbook and look in the project explorer under Microsoft Excel Object you'll see something like: Sheet1 (Sheet1) and you can refer to a sheet as simply Sheet1 without quotes or using the collection syntax, e.g.: Sheet1.Select However, I can't figure out how to use this syntax while referring to workbooks other than the active workbook. Doug "tolgag " wrote in message ... Hi Doug, Since you can call worksheets only from a collection (not directly with their names), you need to use an object variable or type the collection Try this : Dim xsThisWorksheet as Worksheet Set xsThisWorksheet = Workbooks(WorkbookIndex).Worksheets(SheetIndex) you can have the same result by using workbookname and sheetname. But don't forget to put them into ", if you use names. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
[=Sheet1!A1] - if i use Column A1 ('Sheet1') / A2 ('Sheet2') | Excel Worksheet Functions | |||
How do I set up a workbook so changing Sheet1 changes all sheets? | Excel Worksheet Functions | |||
copy sheet1 from all open workbooks to one workbook | Excel Programming | |||
How? Force Sheet1 to display each time the workbook is opened. | Excel Programming | |||
Sheet1 object not Worksheets("Sheet1") | Excel Programming |