Have you ever tried to learn about CSng Function In your Excel Spreadsheet? In this tutorial, we will guide you about what is CSng Function in VBA Excel Office 365. Let’s get them below!! Get an official version of MS Excel from the following link: https://www.microsoft.com/en-in/microsoft-365/excel
CSng Function
- The CSng function is a VBA function that converts any data type to a single-precision floating-point number (“given that it is a number”).
- It is used in the CSng function to convert text formatted numbers into actual numbers.
CSng Function Syntax
CSng(expression)
Syntax Explanation:
expression: It can be any expression. A text or a method that returns some values.
Example-Convert Text to Number using VBA
- Firstly, in the Excel Worksheet, you have to go to the Developer Tab.
- Then, you need to ** ** select the Visual Basic option under the Code section.
- Now, you have to copy and paste the code given below.
Sub TextToNumber()
stri="5.5"
stri = CSng(stri)
debug.print stri
End Sub
- After that, you need to save the code by selecting it and then close the window.
- Again, you have to go to the Excel Spreadsheet , and click on the Developer Tab.
- You need to choose the Macros option in the Code section.
- Now, you have to make sure that your macro name is selected and click the *Run * button.
- Finally, the CDec function converts given expression into a decimal number , and it displays output in a Worksheet.
End of Era
We hope that this tutorial gives you guidelines on what is CSng Function in VBA Excel Office 365. ** Please leave a comment in case of any **queries, and don’t forget to mention your valuable suggestions as well. Thank you so much for Visiting Our Site!! Continue learning on Geek Excel!! *Read more on Excel Formulas *!!
Read Next:
- How to use the XNPV function in Excel office 365?
- Excel Formulas to Highlight the Cells that End with Given Value!!
- Excel Shortcut for “Select to End of Cell” in the Worksheet!!
- Excel Shortcuts: Delete to the End of Line in the Spreadsheet!!
- Excel Formulas for Counting Cells that End with certain character or text!!




Top comments (0)