Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49948

How to detect if i have float number or integer in cell value

$
0
0
Hi Guys,

i have a function:

Code:

Function CheckVariableType(NamedRange, VariableType) As String

    Dim VarValue As String
   
    VarValue = Application.Range(NamedRange).Value
   
    ''boolean handler
    If VarValue = "Yes" Or VarValue = "No" Or UCase(VarValue) = "FALSE" Or UCase(VarValue) = "TRUE" Then
        If VariableType <> "boolean" Then CheckVariableType = Join(Array(NamedRange, VariableType, "boolean"), Chr(2)): Exit Function
    End If
   
    ''float and integer handler
    If IsNumeric(VarValue) Then
       
        ''float
        If VarValue mod  <> 0 then
            If VariableType <> "float" Then CheckVariableType = Join(Array(NamedRange, VariableType, "float"), Chr(2)): Exit Function
        End If
       
    End If
   
    CheckVariableType = 0
   
End Function

NameRange is named range name and Var Type is my baseline from workbook provided.

In the function i am trying to identify based on cell value of named range what kind of variable i have.
For boolean it is easy as you can see but now i have to identify if variable like "30" is a number and also if we have 30,05 like float or maybe this is integer.

How to do this?
Please help,
Jacek

Viewing all articles
Browse latest Browse all 49948

Trending Articles