VBA/Excel/Access/Word/Data Type/Type Mismatch

Материал из VB Эксперт
Перейти к: навигация, поиск

Catch the type mismatch error

   <source lang="vb">

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

</source>