Before we begin discussing VBA variables, we need to have a fundamental understanding of what data types are and how they are used.
What is a Data Type?
A Data Type tells your computer what type of data you want to store. It’s an easy to remember name - a data type reports the type of data. More specifically, it’s a way for your VBA compiler to let your computer know how much space you want to reserve in your computer’s memory. Fundamentally, that’s all there is to it. Nothing more, nothing less.
Since this is a VBA tutorial for beginners, I’m not going to bore you with a long list of supported VBA data types, their storage capacities and their allowable ranges. I think a lot of tutorials lose readers by jumping right into computer science jargon. Blehk. That’s unnecessary for our purpose here. Suffice it to say, VBA offers over a dozen data types to store numbers, text and objects.
Common Data Types
String, Boolean, Integer and Double are 4 of the most common VBA Data Types. I suspect these 4 data types will be all you need for well over 90% of your VBA macros. The graphic below describes these most common VBA Data Types. Print it out and use it as a cheat sheet.
Most Common VBA Data Types
In this lesson, you learned what a VBA data type was and you were introduced to some of the more common data types. Join us in the next lesson as we introduce tutorials for how to use and declare VBA variables for each of these data types.
If you really want to learn VBA, grab a copy of our Ultimate VBA Training Bundle before reading our next tutorial. We specifically created these cheat sheets to help you get the most out of our upcoming lessons. Together, the set has over 200 practical tips covering the 125 most important topics in Excel VBA. We also stuffed it with 140 helpful macro examples.