What is causing “Automation error Unspecified error” on Worksheet_Activate?

前端 未结 9 2709
庸人自扰
庸人自扰 2020-12-15 00:32

I have a worksheet named \"Dates\" (object name is A_Dates) that needs to be calculated when it is activated (It may be worth noting that this is in my Personal macro workbo

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 00:57

    Whenever I get strange errors like this, the first thing I do is clean the code with http://www.appspro.com/Utilities/CodeCleaner.htm. It's a free add-in, but you can do it manually too. Just copy your code out of the module and into a text file (or right click and Export). Then delete the code in the module, compile and save, and put the code back in.

    When Excel compiles "on the fly" it's creating p-code which then gets compiled to machine code. Sometimes, particularly with heavy editing, the p-code gets corrupted. Copying the code out, deleting it, and copying back in forces Excel to regenerate the p-code.

    I've solved some really strange behavior with this method. Hopefully it works for you too.

提交回复
热议问题