Set objectvar = [New] expr | Nothing
Assigns an object reference to an object variable.
|objectvar||The name of the variable.|
|expr||The name of the object you want to assign.|
|* When you use the Set statement to assign an object variable, a reference to the object is created.|
* More than one object variable can refer to the same object.
* Any change to the object will be reflected in all the variables that refer to it.
* When you use the New keyword you are actually creating a new instance of that object.
* To be valid, objectvar must be an object type consistent with the object being assigned to it.
* The Dim, Private, Public, ReDim, and Static statements only declare a variable that refers to an object.
* No actual object is referred to until you use the Set statement to assign a specific object.
* For more information, refer to the Data Types > Object page.
* For the Microsoft documentation refer to learn.microsoft.com
Dim objWorkbook As Workbook
Set objWorkbook = Workbooks.Add
Set objWorkbook = Nothing
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited Top