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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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