【VBA】标准Sub/Function定义,带ScreenUpdating、On Error GoTo

时间:2022-11-06 09:35:32

【说明】

标准Sub/Function定义,带ScreenUpdating、On Error GoTo

Sub AutoFillRole()
    '--------------- ERROR MSG------------------------------
    On Error GoTo errorhandle:
    'On Error Resume Next
    '--------------- ERROR MSG------------------------------
    Application.ScreenUpdating = False






    Application.ScreenUpdating = ture

    '--------------- ERROR MSG------------------------------
    Exit Sub
errorhandle:
    If Err.Number > 0 Then
        MsgBox Err.Description & " " & Err.Number
    End If
    '--------------- ERROR MSG------------------------------
End Sub

 

Function FindRole(key As String) As String
    '--------------- ERROR MSG------------------------------
    On Error GoTo errorhandle:
    'On Error Resume Next
    '--------------- ERROR MSG------------------------------
    Application.ScreenUpdating = False
    






    Application.ScreenUpdating = ture
    '--------------- ERROR MSG------------------------------
    Exit Function
errorhandle:
    If Err.Number > 0 Then
        MsgBox Err.Description & " " & Err.Number
    End If
    '--------------- ERROR MSG------------------------------
End Function