Data Type - Object

This data type contains a reference (or an address) to an actual object.
This can be used to contain any type of object (or Reference Type).
This data type uses 4 bytes.
The default value is Nothing.

Dim myObject As Object 

Avoid This Data Type

Using the generic Object data type is much less efficient than using the specific object declaration.
Whenever you use this data type it will always use late binding.
You can find out if an Object variable has been set by using the "Is Nothing" keywords.
It makes your code less readable.


The reasons for this is because Excel cannot tell what type of object the variable refers to until the program is running, which obviously consumes some execution time.
This is referred to as late binding and can make programs run significantly more slowly.



Early Binding

Dim oWorkbook As Workbook 

more details


Late Binding

Using the Object data type will declare the variable using late binding.

Dim oWorkbook As Object 

more details


Most methods return values, however some return objects. You cannot assign an object to a variable using an equals sign. Instead you must use the "Set" statement.


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext