Excel VBA basics: Data types, DIM and SET (Learn to use them correctly)
Excel VBA basics: Data types, DIM and SET (Learn to use them correctly)
Excel VBA basics: Data types, DIM and SET (Learn to use them correctly)
 

 
It’s best practice to declare your Excel VBA variables before you use them. Declaring variables means that you give VBA a heads up that it needs to free up some memory space for your variables which will in most cases be less than the default. That's why it's important to understand the concept of data types and how much memory space each of these types will take. 
 
The less memory you allocate to a variable, the faster your code will run. I show the range associated to each data type - such as numbers, text, date, currency etc in the video. By default VBA assigns the data type “variant” to each variable. Variant means it changes depending on the data type so is it text, number or date. It will allocate around 16 bytes of memory if it’s a number and 22 bytes + length of string. 

Related topics:

Post a Comment

Previous Post Next Post