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 types from here.
Syntax
CVar(Expression)
Arguments
Expression: The value which you want to convert to a string data type.
Example
To practically understand how to use the 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 used the CVARvto convert that value into a variant data type and it has returned Excel Champs in the result.
More Tutorials
⇠ Back to VBA Function List | What is VBA in Excel
Helpful Links – Developer Tab – Visual Basic Editor – Run a Macro – Personal Macro Workbook – Excel Macro Recorder – VBA Interview Questions – VBA Codes