Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[=Sheet1!A1] - if i use Column A1 ('Sheet1') / A2 ('Sheet2') Lawrence C H Tan Excel Worksheet Functions 0 January 19th 07 08:29 PM
How do I set up a workbook so changing Sheet1 changes all sheets? rach1027 Excel Worksheet Functions 1 June 7th 05 10:12 AM
copy sheet1 from all open workbooks to one workbook Mike[_61_] Excel Programming 2 October 31st 03 02:16 PM
How? Force Sheet1 to display each time the workbook is opened. lothario[_26_] Excel Programming 2 October 17th 03 06:40 AM
Sheet1 object not Worksheets("Sheet1") onedaywhen Excel Programming 2 August 12th 03 12:38 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"