You have to be careful when you check for a Caption like this
"CName = ctl.Controls(0).Caption". If a Control doesn't have a label then you will get an error "Run time Error 2467".
I wrote some code recently to make sure that a Control had a label to avoid this particular error. Actually, the code did the opposite, it checked to see if a label had a Control. VBA is funny like that, you can't say does this or that object exist? If you try and look at an object directly, an object that does not exist, then you automatically get an error.
The code is in the CallCalled Class module that can be found HERE:-
You could handle "Run time Error 2467"... But, it's considered good practice to NOT use avoidable errors to control the logic of your code. But then that begs the question if the object doesn't exist, then how do you access the object to check if it exists or not? How do you ask the question:- "Does this object exist?"
The solution is to remember that all objects have a name, and all objects belong to a Collection. Instead of directly testing to see if an object exists, and by doing so causing an error, you pass the objects name into code which runs through the collection and says, do you have a member of this collection with this name? If yes then the object exists, if no then the object does not exist...
In other words you never touch the object, you just look for a missing object, an object missing from the collection.
It took me many hours, nay, many days, nay, many months to learn this lesson! Here endeth the 255th lesson...
Note to Self, an alternative method of finding if the control has a label or not might be to access the controls own control collection. It's hinted at in this line "Ctrl.Controls(0).Caption"... In theory the 0 is an index to the Control in the collection of the Controls of "Ctrl"... You might be able to ask a different question, you could ask does this control have a control 0? --- no idea if it will work!