Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / April 2007

Tip: Looking for answers? Try searching our database.

Excel Worksheets collection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Labosh - 27 Apr 2007 14:42 GMT
Greetings, all:

I am in the midst of teaching some C# and I do not have Excel in front of
me, but a student posed a question about how to refer to a given worksheet
inside a workbook.

Can I say something like this?

exlApp.Workbooks(0).Worksheets(0)...

to refer to the first worksheet of the first workbook?

Can someone verify the syntax?

Are these collections0-based or 1-based?

Signature

Peace & happy computing,

Mike Labosh, MCSD MCT
Owner, vbSensei.Com
"Escriba coda ergo sum." -- vbSensei

Jim Rech - 27 Apr 2007 14:52 GMT
Both collections are 1 based.  The workbook indexing apparently depends on
the order opened so it would be pretty unreliable.  You should use the
workbook's name Workbooks("abc.xls") or ActiveWorkbook.

I almost always use Worksheets("Sheetname"), if I know the name, in
preference to an index.  Within a project though I'd first use the sheet's
VB Codename since it does not change with sheet order or name.  That is not
easy to use outside of the project though.

Signature

Jim

> Greetings, all:
>
[quoted text clipped - 11 lines]
>
> Are these collections0-based or 1-based?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.