Returns the data type of the variable as a string (String).

varnameThe data type name, expression or variable (Object).

* The string returned by this function is the class name.
* For more information, refer to the TypeName Function page.
* You can use the VARTYPE function to return a number indicating the data type.
* The equivalent .NET function is Microsoft.VisualBasic.Information.TypeName
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print TypeName("String")   '= "String"  
Debug.Print TypeName(1) '= "Integer"
Debug.Print TypeName(10.4) '= "Double"

Dim vVariant As Variant
sVariant = CDec(10.5)
Debug.Print TypeName(vVariant) '= "Decimal"

Dim sTemp As String
Debug.Print TypeName(sTemp) '= "String"

If TypeName(Application.Selection) = "Range" Then
End If

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited Top