What is VBA CVAR Function
The VBA CVAR function is listed under the data type conversion category of VBA functions. When you use it in a VBA code, it converts an expression into a variant data type. In simple words, a variant data type value can hold numeric, string, or date values. Learn more about variant data type from here.
how to use it
To use VBA's CVAR function you need to understand its syntax and arguments:
Expression: The value which you want to convert to a string data type.
Example to use CVAR Function in VBA
To practically understand how to use VBA CVAR function, you need to go through the below example where we have written a vba code by using it:
Sub example_CVAR() Range("B1").Value = CVar(Range("A1")) End Sub
In the above example, we have used the value from cell A1 (Excel Champs) and then we have used the CVARvto convert that value into a variant data type and it has returned Excel Champs in the result.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.