Thread: [Solved] Proper use of lbl_Exit:
View Single Post
 
Old 11-16-2022, 01:49 PM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 554
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Labels are typically used with GoTo and an Exit label would typically be used with some error handling code so that there is a single exit point. I have known some programmers use them simply to mark sections of code, though. In this case you don’t need the label, though it is neither useful nor doing any harm.

Setting an object variable to nothing is a habit some of us long timers have because VBA has/had the reputation of being a sullen teenager when asked to clean up its room. In theory VBA should release allocated memory when an object variable goes out of scope, but that didn’t always happen. By explicitly destroying the object you keep things clean and ensure allocated memory gets released.
Reply With Quote