I am wonder why in excel VBA , Worksheets(1) returns an Object(variant) .
I expected that returning type will be a Worksheet object.
I am wonder why in excel VBA , Worksheets(1) returns an Object(variant) .
I expected that returning type will be a Worksheet object.
Have you answered your own question?
If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)
You can't do one thing. XLAdept
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin
Hi
Macro sheets are also part of the Worksheets collection.
Don
Please remember to mark your thread 'Solved' when appropriate.
Have you answered your own question?
I don't know answer . and I want to figure out how VBA designer think about worksheets.
Last edited by farshid_mi; 02-04-2018 at 06:25 PM.
No, If you have a macro sheet , you can not access it in worksheets collection. you can test it and see the following code doesn't show macro sheet name:Macro sheets are also part of the Worksheets collection.
(I know sheets is a collection contains all sheets type like chart sheet , macro sheet , ... )Please Login or Register to view this content.
Last edited by farshid_mi; 02-04-2018 at 06:28 PM.
How are you getting Object from Worksheets(1)?
When I try this in the Immediate Window it returns Worksheet.
Please Login or Register to view this content.
If posting code please use code tags, see here.
If you type worksheets(1) , the list member dose not show . when VBE can not recognize object type it happens also you can see the tool tip when typing "Worksheets( " , in the tool tip you can see "_Default(index) as object " .
(I know that we can define a variable as worksheet to access member list in VBE but I want to figure out why worksheets(1) tool tip says it return Object and why we can not access its list member in VBE)
Last edited by farshid_mi; 02-04-2018 at 07:10 PM.
Intellisense doesn't appear because the Worksheets method can return either a single worksheet (with all the usual properties or methods) or an array of worksheets, which have their own methods (like FillAcrossSheets)
That's why it's convenient to assign a worksheet variable.
Last edited by shg; 02-04-2018 at 08:37 PM.
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks