LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Ken is offline
external usenet poster
 
Posts: 207
Default automation error 440 when adding to collection

I have a collection built from data in a range, and want to augment
that collection with data from another range. I also want to keep
track of the the new data by putting it in a listbox. The following
code works as far as augmenting the list

Set R = Range("Table14")

we = Range("Week_ending").Value
Count = EmpList.Count

For i = 1 To R.Rows.Count

If R.Cells(i, 1).Value = we - 7 Then
Set E = New Employee
E.Badge = R.Cells(i, 3)
E.LName = R.Cells(i, 4)
E.FName = R.Cells(i, 5)
On Error Resume Next
Call EmpList.Add(E, CStr(R.Cells(i, 3)))
ListBox3.AddItem CStr(E.Badge) 'this should
only happen when E is actually added to EmpList
ListBox3.List(ListBox3.ListCount - 1, 1) = E.LName
50
End If

Next i

Since I don't want to add the employees to listbox3 if they are
already in the collection, I thought I should be able to make the
following simple change to the On Error Resume Next line

Set R = Range("Table14")

we = Range("Week_ending").Value
Count = EmpList.Count

For i = 1 To R.Rows.Count

If R.Cells(i, 1).Value = we - 7 Then
Set E = New Employee
E.Badge = R.Cells(i, 3)
E.LName = R.Cells(i, 4)
E.FName = R.Cells(i, 5)
On Error GoTo 50
Call EmpList.Add(E, CStr(R.Cells(i, 3)))
ListBox3.AddItem CStr(E.Badge)
ListBox3.List(ListBox3.ListCount - 1, 1) = E.LName
50
End If

Next i

This causes an "Automation Error" 440 which I can't seem avoid. I
have tried clearing the error and moving the On Error statement
around, but, the second time through the If-End If loop it always
crashes.

Is there a fix to this, or another way to keep track of the names that
get added?

Thanks

Ken
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding validation fails with automation error [email protected] Excel Programming 4 February 13th 08 08:30 PM
Adding to A Collection Max Excel Programming 2 October 31st 07 07:54 PM
Automation Error(-2147467259) in Properties Collection Bob Phillips[_6_] Excel Programming 1 April 14th 05 07:08 PM
Automation Error(-2147467259) in Properties Collection Bob Phillips[_6_] Excel Programming 0 April 14th 05 04:27 PM


All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"