VBA CSng function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

CSng Function Description

The VBA CSng function converts an expression (variable) to Single data type.


The syntax for the CSng function in VBA is:

CSng( expression )


An expression / variable that is to be converted to Single data type.

Other Notes

If the expression / variable can’t be converted to a Single, the function with return Error code 13: Type mismatch.

Example usage

The CSng function can be used in VBA code. Let’s look at some VBA CSng function examples:

CSng 10
'Result: 10

CSng 10.2
'Result: 10.2

CSng 10.111119
'Result: 10,11112 

Simply the best place to learn Excel VBA