Hi all,
I have a workbook database that I've built. I want to create a list of the worksheets that I have created myself. I want to make the list of the worksheet codenames, specifically, because the average user can accidentally change the name of the worksheet but cannot accidentally change the codename. Once I've made this list, I want to run a macro in the Before Close event that checks every worksheet in the workbook against this list. If the worksheet is not included in the list, I want that worksheet to be deleted.
The idea is to remove any worksheets that a user has created themselves BEFORE the workbook closes. For a hundred different reasons that I won't get into on this forum, I can't run a Workbook.Protect to prevent worksheet creation. Just trust me, I can't. So I need to build a sort of protected group of worksheets that I do not want to be deleted, and then I want to get rid of all the other ones. And it gets more complex after that: I have a userform set up where a user can legitimately add a worksheet to the database. I want to add code lines that will automatically include any worksheets created this way in this special group of worksheets.
After doing extensive reading online, I'm thinking that a collection is the best way to go. But I have never made a collection or used a class module before. I have absolutely no idea how to do so, and not for lack of trying to understand. I apparently have a mental block for the concept.
Please be very specific when you explain, and please don't just give me links to online tutorials, because I just spent my entire afternoon Googling and have read at least the first ten tutorials that pop up in searches about building collections, and I'm still completely confused and, to be honest, rather cranky.
Thanks for any help you can provide!
Bookmarks