Assigning values and objects to variables.
When to use
When you wish to assign something to a variable that you have created.
How you assign something to a variable depends on the type of data you wish to assign:
- Values are set using the = statement (e.g. VariableName = 5)
- Text variables must be wrapped in quotes (e.g. VariableName = “Text”)
- Object variables are assigned using the Set statement (e.g. Set VariableName = Target [worksheet, range, etc.])
Common Data Types
|Type||Use For||Assign Via|
|Integer||Numbers between -32,768 and 32,767||=|
|Long||Really large numbers (no decimals)||=|
|Double||Really large numbers (with decimals)||=|
|Objects||Object, workbook, worksheet, range, etc...||Set|
|Variant||Determined at runtime||Set or = (as req'd by true type|
Lesson notes are only available for subscribers.