VBA CSng Function

CSng Description

Converts a value to a single-precision number.

CSng Syntax

In the VBA Editor, you can type  “CSng(” to see the syntax for the CSng Function:

The CSng function contains an argument:

Expression: Any string or numeric expression.

Examples of Excel VBA CSng Function

Sub CSng_Example()
    Dim sngVal As Single
    
    sngVal = CSng("3.141592653589")
    MsgBox sngVal
End Sub

Running the above VBA code, it will display a message box as following.