What is the purpose of using `Exit Sub` in VBA error handling?

Responsive Ad Header

Question

Grade: Education Subject: Support
What is the purpose of using `Exit Sub` in VBA error handling?
Asked by:
62 Viewed 62 Answers

Answer (62)

Best Answer
(279)
The `Exit Sub` statement is used within a `Sub` procedure to immediately terminate the procedure's execution. In the context of error handling, it allows you to exit a `Sub` when a specific error occurs, preventing further code execution that might be problematic or unnecessary.