Why does "Dim wkSource As Worksheet" work?

  • Thread starter Thread starter Cloudfall
  • Start date Start date
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.
 
Back
Top