Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation Error: Object has disconnected from its client message Copy and Paste

Status
Not open for further replies.

Phrazel

Technical User
Sep 30, 2015
4
US
Hello -
I have created a basic copy and paste macro (VBA Excel 2010) that was working fine, but when I went to expand the amount of sheets I am copying to, I started receiving an Automation Error: Object has disconnected from its client message:
I run this code over about 30 times with "Daffy, Duck" the only thing changing, almost at the end I get the error. Any help is greatly appreciated.
Here is the code:
Code:
Sub Duck()
'
' Macro1 Macro
'

'

    Application.CutCopyMode = False
    Application.ScreenUpdating = False
    Sheets("Pivot Data Sheet").Select
    
    ActiveSheet.Range("$A$1:$BD$184").AutoFilter Field:=12, Criteria1:="Fail"
    ActiveSheet.Range("$A$1:$BD$184").AutoFilter Field:=16, Criteria1:="Daffy, Duck"
    
    ActiveSheet.Range("A2:BD50000").Copy Destination:=Sheets("Daffy, Duck").Range("A2")
    
    ManagerSortedData = Empty
    Application.CutCopyMode = False
    Sheets("Pivot Data Sheet").Select
    ActiveSheet.ShowAllData
    

End Sub
 
Hi,

Your code errors on ManagerSortedData = Empty

Other than that, your code ran sucessfully.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Thank you I removed that line - I no longer get the error but the CPU and Memory spikes and it locks up.
Is there any other way to clear the data from memory before moving on to the next one?
 
You most likely COPY unnecessary cells.
Code:
Sub Duck()
'
' Macro1 Macro
'

'

    Application.CutCopyMode = False
    Application.ScreenUpdating = False
    
    With Sheets("Pivot Data Sheet")
        With .UsedRange
            .AutoFilter Field:=12, Criteria1:="Fail"
        
            .Copy Destination:=Sheets("Daffy, Duck").Range("A2")
        End With
    '    ManagerSortedData = Empty
        .Select
        .ShowAllData
    End With
    
    Application.CutCopyMode = False
    Application.ScreenUpdating = True

End Sub

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Question: Are you using Windows 10? I got the same error in IE automation on Windows 10. Not on Win8,7,Vista or XP. Only in Win10.
 
Thank you very much!
It works great now
 
So tell us what you did to achieve success.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top