What is VBA CSNG Function
The VBA CSNG function is listed under the data type conversion category of VBA functions. When you use it in a VBA code, it converts an expression into a single data type. Actually it converts a value into a single-precision floating-point number. You can read more this format from here.
how to use it
To use VBA's CSNG function you need to understand its syntax and arguments:
- Expression: The value which you want to convert to a single data type.
Example to use CSNG Function in VBA
To practically understand how to use VBA CSNG function, you need to go through the below example where we have written a vba code by using it:
Sub example_CSNG() MsgBox CSng("699.9999999") End Sub
Below are some important points which you need to take care while using CSNG function in VBA.
- If the value specified is a value other than a number or a string which can’t be recognized as a number, VBA will return the run-time 13 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.