Thursday, February 12, 2015

Excel VBA Automation Error: The object invoked has disconnected from its clients

Error:
Excel VBA Automation Error: The object invoked has disconnected from its clients

Reason:
If you have come across above error, it would mainly because of 
        Selection.Insert Shift:=xlDown
statement in your vba code. 

i.e : you are trying to copy and insert the previous row which contains formulae. I know it would have been working flawlessly all these years but suddenly Excel felt like it needs have some fun playing with you. No problem, as we all know MS Excel has stretched beyond its capabilities let it have some fun. Now how to tame it..

Solution:
There are many workarounds suggested on many forums. But for me for the specific task of inserting the previous formulae filled rows down, I had to replace the Copy and xlDown code with a code to first insert as many blank rows that are required and then copy the formulae and paste over the new blank rows.

Now out of the blue why did Excel behave like this!!? Only possible reasoning could be corruption in excel sheet. Usually this error occurs in an old/used [or even abused] Excel Workbooks/Worksheets.

Hope this helps!
Have a good one! :)

No comments:

Post a Comment