The Variant data type is the data type for all variables that are not explicitly declared as some other type. The Variant data type has notype-declaration character.
A Variant is a special data type that can contain any kind of data except fixed-length String data. A Variant can also contain the special valuesEmpty, Error, Nothing, andNull. We can determine how the data in a Variant is treated using the VarType function or TypeName function.
We can assign any value at any time within a single module/program. If we don't declare the data type of any variable then it automatically declare as variant data type:
Sub modVariant1()
Dim VData as variant
VData =1234
Msgbox vData
vData="Aman"
Msgbox vData
End Sub
Sub modVariant2()
'In this example, data type is not declared
Dim VData
VData =1234
Msgbox vData
vData="Aman"
Msgbox vData
End Sub