ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Difference between Worksheets. and Sheets. is...? (https://www.excelbanter.com/excel-programming/383526-difference-between-worksheets-sheets.html)

Jay

Difference between Worksheets. and Sheets. is...?
 
Hello all,

This question is just to satisfy my curiousity, as I don't (yet) believe it
has a significant impact on my code.

I came across something and I can't seem to find the answer. Everything
I've found mentions 'how' to use the collection, and not 'why' to use it.

If I use Sheets("Sheet1").Select, then the sheet is selected without error.
If I use Worksheets("Sheet1").Select, I get a "Subscript out of range" error
(run-time error 9).

I haven't got the slightest idea why there's a difference. Any ideas?
Appreciate anything you might have (ideas, links, suggestions).

In most of my code, when accessing cell values I use:
Worksheets("Sheet1").Cells(1, 1).Value = "some random string"
This has never been an issue. Never really used ther Sheets

Thanks,
Jay

merjet

Difference between Worksheets. and Sheets. is...?
 
Sheets include Chart sheets. Worksheets don't.

Hth,
Merjet



Jay

Difference between Worksheets. and Sheets. is...?
 
Well I'll be damned, that makes sense.

Thanks!

Jay

"merjet" wrote:

Sheets include Chart sheets. Worksheets don't.

Hth,
Merjet





All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com