Home
Do you put Exit Sub before End Sub?
  v1.0 Posted at 26/04/2018 7:27 AM by Tiago Araujo
Do not put "Exit Sub" statements before the "End Sub". The function will end on "End Sub". "Exit Sub" is serving no real purpose here.

Private Sub SomeSubroutine()
'Your code here....
Exit Sub ' Bad code - Writing Exit Sub before End Sub.
End Sub

Bad example​

Private Sub SomeOtherSubroutine()
'Your code here....
End Sub

Good example​

We have a program called SSW Code Auditor to check for this rule.


Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments:

    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.