VBA returning an "object invoked has disconnected from its clients" error then crashing Excel

d0rian

Active Member
Joined
May 30, 2015
Messages
313
Office Version
  1. 365
I'm re-creating my main work file in Excel 365 (had used 2007 until now).

I copy-pasted what looks like completely standard sorting VBA code (which works just fine) from my 2007 file, but it behaves oddly when run in my new 365 workbook:
>> It runs fine the FIRST time I run it.
>> But if I then immediately try to run it a second time, it returns an "Automation error - the object invoked has disconnected from its clients" error.

See the blue block in image -- that's the offending piece of code. If I comment it out, the VBA runs fine. But if left in, it generates the error / crashes Excel.
EDIT: I was wrong, it's NOT just the blue / sorting piece that causes the crash...I have it commented out, and still getting the error shown / excel-crash. Ugh, so yeah: can't believe this super simple snippet is causing such a weird headache(?)
 

Attachments

  • error2.JPG
    error2.JPG
    158 KB · Views: 13

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi dOrian. A couple of things. First please post code not pictures of code. You seem to be missing a With sheet and some "."'s before Range at the start of the sub. Using ActiveWorkbook can also be troublesome and can be replaced with ThisWorkbook which will not cause problems. As for your error, this can be caused by the ClipBoard crashing and you are doing alot of copy and pasting. You need to clear the clipboard after pasting. There's some code at this link for that...
You should also use..
Code:
Application.CutCopyMode = False
after pasting. HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top