Search code examples
excelvbanumericalmismatch

Excel VBA Run-time error '13' Type mismatch when value isnt numerical


I have the below code that's returning a mismatch error when the value isn't numerical. What would I change?

If Sheet3.Cells(4, 8).Value <= 182 Then
    Call ThreeSpells
End If

Thanks in advance :)


Solution

  • Something like this

    Dim MyVar, MyCheck
    MyVar = Sheet3.Cells(4, 8).Value
    MyCheck = IsNumeric(MyVar) 'Returns True
    
    If MyCheck = True Then
      If Sheet3.Cells(4, 8).Value <= 182 Then
         Call ThreeSpells
      End If
    Else
     'msgbox or what you want
    End If