Excel CSng Function (VBA)
-function/csng-function-vba-code.jpg)
How to use the CSng Function (VBA)
This Excel tutorial explains how to use the Excel CSng function with syntax and examples using VBA.
SUMMARY:
The Excel VBA CSng function converts an expression into a Single data type.
For example,
- The VBA Code CSng(22426.55) would return 22426.55
- The VBA Code CSng(33.955555) would return 33.9555
PURPOSE:
To converts a value to into Single precision floating point numbers.
RETURN VALUE:
The CSng function returns a Single precision numeric value.
SYNTAX:
CSng( expression )
ARGUMENTS:
The CSng function syntax has the following arguments:
- expression: Required. The expression is that you want to convert to a Single precision number value.
- The "expression" can be any value between -3.4028235E+38 and 3.4028235E+38
- If "expression" is outside the range of the data type being converted to, an error occurs.
REMARKS:
- The CSng function can only be used in VBA code in Microsoft Excel.
- The Single data type can hold integer values from 1.401298E-45 through 3.4028235E+38 for positive values
- The Single data type can hold integer values from -3.4028235E+38 through -1.401298E-45 for negative values
- The Single data type is a Value data type.
- VBAs hexadecimal notation symbol is "&H"