'DEBUT DE MACRO
On Error GoTo ErrorHandler
'FIN DE MACRO
ErrorHandler:
appelmacrodansmodulespecifique (Err.Number)
End Sub
Sub appelmacrodansmodulespecifique(MonErreur)
Select Case MonErreur
Case 6
MsgBox 'Déclaration Byte y a pas bon ' & Err.Description
Case 9
MsgBox 'La feuille y a pas bon ' & Err.Description
Case 1004
MsgBox 'Le chemin y a pas bon ' & Err.Description
Case Else
MsgBox 'Une erreur non gérée s'est produite, téléphoner à Thierry !! lol' & _
vbCrLf & Err.Number & ' ' & Err.Description
End Select
End Sub
Sub Bouton1_QuandClic()
Dim el, tablo
'DEBUT DE MACRO
On Error GoTo ErrorHandler
For Each el In tablo
MsgBox el
Next el
'FIN DE MACRO
ErrorHandler:
appelmacrodansmodulespecifique (Err.Number)
End Sub
Sub appelmacrodansmodulespecifique(MonErreur)
Select Case MonErreur
Case 13
MsgBox 'y'a pas bon mon gars ' & Err.Description
End Select
Resume
End Sub
Sub MaMacro()
Dim ActionQuanddErreur As Long
...
ErrorHandler:
ActionQuandErreur=GestionErreur(Err)
Select Case ActionQuandErreur
Case 1
Resume
Case 2
Resume Next
...
End Select
End Sub
Function GestionErreur(iErrNum) As Long
Select Case iErrNum
Case Erreur_n°1
...
GestionErreur=1
Case Erreur_n°2
...
GestionErreur=2
End Select
End Function