I am writing some code in VBA that will use a single procedure to insert multiple commandbuttons onto the active worksheet. The user will click a form button on the sheet which, in turn, will generate two new buttons and their associated code lines in the worksheet code module.

The following code successfully generates the first commandbutton and its code lines:

Please Login or Register  to view this content.
The above code is called from the following procedure:

Please Login or Register  to view this content.
Excel crashes when I add the code for the CreateDeleteSectionButton(B):

Please Login or Register  to view this content.
As you can see, the code for CreateDeleteSectionButton is identical in form to the code for CreateAddSectionButton. But, for some reason, running the code a second time within the same subprocedure is making Excel suddenly shutdown. I read on the MS help site that the problem could be due to unqualified references, which is why I added the oXL, oWB and oWS prefixes. But that didn't fix the problem. I would greatly appreciate any help.