ScreenUpdating x On Error GoTo ErrorHandler

0

With the code below:

Application.ScreenUpdating = False
Application.EnableCancelKey = xlDisabled
On Error GoTo ErrorHandler

'Código

Exit Sub
ErrorHandler:Application.ScreenUpdating = True

'Código caso erro

End Sub

ScreenUpdating = False coming before On Error GoTo ErrorHandler in code, does it interfere with the application of On Error?

    
asked by anonymous 21.10.2018 / 02:48

1 answer

2

Application.ScreenUpdating = False disables screen refresh and always at the end of code you have to enable Application.ScreenUpdating = True . It does not interfere with On Error GoTo ErrorHandler but Application.ScreenUpdating = True that is after, it will not run if an error does not occur. You can do the following:

Application.ScreenUpdating = False
Application.EnableCancelKey = xlDisabled
On Error GoTo ErrorHandler

'Código
fin:
   Application.ScreenUpdating = True
Exit Sub

ErrorHandler:

'Código caso erro

GoTo fin

So, even if it does not give an error or if there is an error, it will activate the screen update before finishing on Exit Sub

    
22.10.2018 / 19:25