Automation Error in VBA

mayur553

New Member
Joined
Oct 19, 2010
Messages
12
Hi Guys need help. The below code runs fine on one laptop and gives an error on other. The error is on line "Sheets("List of List").Range("A2:A1000").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo"

Am not sure whats wrong. Am getting the following error:

Runtime error '-2147417848 (800100108)': Automation Error The object invoked has disconnected from its clients.

Code:
With Sheets("Raw Data") lRow = .Columns("D:K").Find(What:="*", After:=Cells(1, 4), SearchOrder:=xlByRows, _
 SearchDirection:=xlPrevious, SearchFormat:=False).Row
 Set rng = .Range("D7:K" & lRow)
 Set Dic = CreateObject("Scripting.Dictionary")
 For Each Dn In rng
 If Dn.Value <> "" Then
 Dic(Dn.Value) = ""
 End If
 Next
 Sheets("List of List").Range("A2").Resize(Dic.Count) = Application.WorksheetFunction.Transpose(Dic.Keys)
 Sheets("List of List").Range("A2:A1000").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo
 End With
 
 With Sheets("Raw Data")
 lRow = .Columns("D:K").Find(What:="*", After:=Cells(1, 4), SearchOrder:=xlByRows, _
 SearchDirection:=xlPrevious, SearchFormat:=False).Row
 Set rng = .Range("D7:D" & lRow)
 Set Dic = CreateObject("Scripting.Dictionary")
 For Each Dn In rng
 If Dn.Value <> "" Then
 Dic(Dn.Value) = ""
 End If
 Next
 Sheets("List of List").Range("B2").Resize(Dic.Count) = Application.WorksheetFunction.Transpose(Dic.Keys)
 Sheets("List of List").Range("B2:B1000").Sort Key1:=Range("B1"), Order1:=xlAscending, Header:=xlNo
 End With


 With Sheets("Raw Data")
 lRow = .Columns("D:K").Find(What:="*", After:=Cells(1, 4), SearchOrder:=xlByRows, _
 SearchDirection:=xlPrevious, SearchFormat:=False).Row
 Set rng = .Range("E7:E" & lRow)
 Set Dic = CreateObject("Scripting.Dictionary")
 For Each Dn In rng
 If Dn.Value <> "" Then
 Dic(Dn.Value) = ""
 End If
 Next
 Sheets("List of List").Range("C2").Resize(Dic.Count) = Application.WorksheetFunction.Transpose(Dic.Keys)
 Sheets("List of List").Range("C2:C1000").Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlNo
 End With
End Sub
 
Last edited:

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Forum statistics

Threads
1,217,172
Messages
6,135,028
Members
449,907
Latest member
moosa77

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