The VBA CCUR function is listed under the data type conversion category of VBA functions. When you use it in a VBA code, it converts a number into a currency data type. In simple words, in currency data type you have 15 digits to the left of the decimal place and a maximum of 4 digits to the right of the decimal place (-922,337,203,685,477.5808 and 922,337,203,685,477.5807).
- Expression: The numeric value which you want to convert to the currency data type.
To practically understand how to use VBA CCUR function, you need to go through the below example where we have written a vba code by using it:
Sub example_CCUR() Range(“B1”).Value = CCur(Range(“A1”)) End Sub
In the above example, we have used the value from the cell A1 where we have a number (8.5694) and then we have used the CCUR function to convert that value into currency data type and it has returned $8.57 in the result.
- If the value specified is a value other than a number or a number which can’t be recognized as a number, VBA will return the run-time 13 error.
- And if the range of the value supplied is out of -922,337,203,685,477.5808 to 922,337,203,685,477.5807 VBA returns the run-time 6 error.