Why does "Dim wkSource As Worksheet" work?

C

Cloudfall

I found some great code for copying rows, that pass a particular test,
from one worksheet to another in this newsgroup and got it working in
my project. I'm trying to become a good programmer so I'm starting to
use style guidelines to produce professional-quality code. OK. I'm
tidying up the code and I find:

Dim wkSource As Worksheet 'The source worksheet.

Please note that worksheet is not highlighted in blue like the other
data types.

Later I set this variable to a worksheet:

Set wkSource = Worksheets("Intermediate") 'sets the source worksheet
variable.

Worksheet is not a data type. Am I correct in assuming that the
compiler doesn't mind the user declaring a variable to be a
non-existent data type and then sets it to be a "variant", or even
"object" in this case? This is all just idle curiosity as the code
works beautifully.
 
B

Bob Phillips

Worksheet is an object type, it is just not a VBA data type, it is part of
the Excel object model.
 
Top