Catch the type mismatch error : Type Mismatch « Data Type « VBA / Excel / Access / Word






Catch the type mismatch error

 
Sub ResetValues()
    On Error GoTo errorHandler
    For Each n In ActiveSheet.UsedRange
        If n.Value <> 0 Then
            n.Value = 1
        End If
TypeMismatch:
    Next n
errorHandler:
    If Err = 13 Then        'Type Mismatch
        Resume TypeMismatch
    End If
End Sub

 








Related examples in the same category