I have Googled a number of threads explaining the difference between "Exit Sub" and "End", and understand that the former only exits the current sub-procedure (returning immediately to the calling procedure), whereas the latter suddenly stops all code completely and suddenly.
But if there is no calling procedure, is there a difference between the two? For example, suppose a module has only one procedure:
Imagine this "Test" procedure is never, ever going to be called from anywhere else. If the "Exit Sub" is replaced with "End", the code seems to have exactly the same effect, since there is no calling procedure. But does "Exit Sub" have any hidden advantages here? Is it still a "cleaner" way to stop the code?
But if there is no calling procedure, is there a difference between the two? For example, suppose a module has only one procedure:
VBA Code:
Sub Test()
Dim s As String
s = InputBox("Surname?")
If s = "" Then
Debug.Print "No name input."
Exit Sub
Else
'Do some stuff
End If
End Sub
Imagine this "Test" procedure is never, ever going to be called from anywhere else. If the "Exit Sub" is replaced with "End", the code seems to have exactly the same effect, since there is no calling procedure. But does "Exit Sub" have any hidden advantages here? Is it still a "cleaner" way to stop the code?