Back to lesson
1. If your variable's data type is not set in the Dim statement, what is the default type applied to the variable when the code begins running?
Whatever is assigned to it
2. What is the best way to ensure that you will always explicitly declare your variables?
In the Visual Basic Editor, type Require Variable Declaration at the top of the code module
Ensure the words "Option Explicit" are visible at the top of the code module
Go to the Tools menu, select Options and check the box for Require Variable Declaration
3. What is wrong with the following line of code? Dim sTitle as String, sBody, wsTarget as Worksheet
wsTarget is not the same data type as the other two variables
sBody is a Variant
The extra variables should be separated with semi-colons (;) not commas
Back to the top
© 2017 GoSkills Ltd.
Skills for career advancement