Which variable types are the bare minimum to teach non-programmers who want to be able to create and modify simple VBA (MS Office) macros?
I start by showing them the concept of variables through using an Excel cell as a temporary storage, then using undefined variables, then show them a simple Dim SummedValue
with no type declaration. Then comes the types, and I always struggle.
String
, Integer
, Boolean
, Double
seem the most important, but maybe Long
(integer) is better, or just Double
is enough for all the numbers? Also, Object variables
are important too with the Set
statement. I don't bother showing them arrays variables
. Or am I better of telling them to use Variant
for everything?
They will be making simple macros for themselves, maybe a few colleagues. Usually start off from a recorded code. They should be able to read and comprehend other's macros too.
Context:
I regularly hold intensive company VBA trainings. These are typically 2 day long trainings (yes, I know, totally not optimal, but I can rarely make the organizing HR understand this). So, 2 days Beginner Training, where I teach them the basics from macro recording through modifying the existing code to the IF statement. Then in a few weeks it is followed by a 2 days long Intermediate Training. This is where I teach them the variables and loops - and make them practice a lot.