What is VBA CCUR Function
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).
how to use it
To use VBA's CCUR function you need to understand its syntax and arguments:
- Expression: The numeric value which you want to convert to the currency data type.
Example to use CCUR Function in VBA
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.
Below are some important points which you need to take care while using CCUR function in VBA.
- 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.
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.