I have a button (Form Control not ActiveX Control) that when pressed, calls a sub procedure inside inside a worksheet module for the worksheet that the button is on.
For whatever reason after opening the workbook the first time I click on the button, it produces a 400 error:
Every time I click on the button after this first time, it runs the sub procedure as expected.
As a test I put a "Stop" command as the first line of the sub and it seems as though the 400 error happens before the sub procedure is even called.
I also tested putting the exact sub procedure in to a new module and assigning the button to that sub procedure. Doing this results in no error - So I can run the sub procedure by clicking on the button if it is outside of the worksheet module, but not inside..
I am so baffled as to why this would happen. I have disabled all add-ins to see if that is what the issue is, but that didn't change anything.
Any ideas for what the problem might be or how I can fix it? I can move all of my code outside of the worksheet modules, but that would be quite a pain, because this same thing is an issue for many programs that I have written, and I would hate to have to change all of them.
For whatever reason after opening the workbook the first time I click on the button, it produces a 400 error:

Every time I click on the button after this first time, it runs the sub procedure as expected.
As a test I put a "Stop" command as the first line of the sub and it seems as though the 400 error happens before the sub procedure is even called.
I also tested putting the exact sub procedure in to a new module and assigning the button to that sub procedure. Doing this results in no error - So I can run the sub procedure by clicking on the button if it is outside of the worksheet module, but not inside..

I am so baffled as to why this would happen. I have disabled all add-ins to see if that is what the issue is, but that didn't change anything.
Any ideas for what the problem might be or how I can fix it? I can move all of my code outside of the worksheet modules, but that would be quite a pain, because this same thing is an issue for many programs that I have written, and I would hate to have to change all of them.