Currency Data Type in Excel VBA explained with syntax and examples. We use the Currency VBA data type to store numbers in integer format and these numbers scaled by 10,000. The default value is 0. The Currency VBA data type conatins range of values between -922,337,203,685,477.5808 to 922,337,203,685,477.5807. The data type Currency can be used store both positive and negative numbers. It is one of the VBA data type and occupies 8 bytes(64 bits) in memory.
Note: The currency VBA data type is useful for money, monetaory or fixed-point calculations. It has type declaration character. It is nothing but character appended to a variable instead of data type. The type declaration character for currency VBA data type is the explanation point(@).
Let us see Data Type Currency Syntax in Excel VBA.
Dim VariableName as Currency
Where VariableName represents the name of the variable.
and Currency represents the type of data.
Here is an example on the Data Type Currency in Excel VBA.
Sub VBAF1_Currency_DataType2() 'Integer Variable Declaration Dim cValue As Currency 'Assign value to currency variable cValue = 888866664444.2222@ End Sub
You can convert an expression to Currency VBA data type using VBA CCur function. Click on the following link to learn about CCur function and complete tutorial and examples.
VBA Data Types
Also read about all other data types.