K
Ken
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
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