VBA Single Data Type in Excel

Single Data Type in Excel VBA

Single Data Type in Excel VBA explained with syntax and examples. We use VBA data type single to store numbers which represents single-precision floating-point variables. The default value is 0 and store decimal values. The VBA data type single conatins range of values -3.402823E38 to -1.401298E-45 for negative values, and 1.401298E-45 to 3.402823E38 for positive values.It is one of the VBA data type. It occupies 4 bytes(32 bits) in memory.

Note: It has type declaration character. It is nothing but character appended to a variable instead of data type. The type declaration character for single VBA data type is the explanation point(!).

VBA Data Type Single Syntax in Excel

Let us see the Data Type Single Syntax in Excel VBA.

Dim VariableName as Single
'or
Dim VariableName!

Where VariableName represents the name of the variable.
and Single represents the type of data.

Example on the VBA Data Type Single in Excel

Here is an example on the VBA Data Type Single in Excel.

Sub VBAF1_Single_DataType()
    
    'Integer Variable Declaration
    Dim iValue As Single
      
    iValue = 1
     
End Sub

Convert an Expression to VBA Data Type Single in Excel

You can convert an expression to Single VBA data type using VBA CSng function. Click on the following link to learn about CSng function and complete tutorial and examples.

VBA CSng Function

VBA Data Types

Also read about all other data types.

VBA Data Types

Leave a Comment

Your email address will not be published. Required fields are marked *