Got any Excel/VBA Questions? Free Excel Help.
The example below shows how CSng can be used in Excel VBA to convert to a Single data type. -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values.
Sub ConvertToSingle() Dim vStr, sinNum vStr = "987654.589765" sinNum = CSng(vStr) MsgBox sinNum End Sub
Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft
See also:
Convert to a String Data Type |
Convert Excel Text To Upper Case |
Excel VBA: Convert to a Variant Data Type |
Free Training Course: Lesson 1 - Excel Fundamentals
See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.