What is a variant data type?
A variant data type is unique to VBA. Variables that aren’t specifically declared are assigned as a variant type, and VBA automatically converts the data to the proper type when it’s used. This is particularly useful when getting values from a worksheet cell when you don’t know in advance what the cell contains. Generally, it’s a good idea to specifically declare your variables (using the Dim statement) because using variants is quite a bit slower.
Variables that aren t specifically declared are assigned as a variant type, and VBA automatically converts the data to the proper type when it s used. This is particularly useful when getting values from a worksheet cell when you don t know in advance what the cell contains. Generally, it s a good idea to specifically declare your variables (using the Dim statement), because using variants is quite a bit slower.