Maldred
Maldred

Reputation: 1104

Add One Object from Collection to another Collection

I've created a class called CASN within this class has a couple variables (which aren't really important here). Basically what I'm trying to do is, create a new collection and add items based on a specific criteria from the original collection.

Once the compare collection is created, then I will compare the two collections against each other and ONLY keep the duplicate values in another new result collection.

Public Function FindDuplicates(col As Collection, wk As String) As Collection

   Dim numOrig As CASN
   Dim numComp As CASN
   Dim result As Collection
   Dim compare As Collection

   For Each numOrig In col
      If (numOrig.Week <> wk) Then
         Set numComp = New CASN
         Debug.Print numOrig.Addressxl   '''' ERROR HERE
         numComp.Addressxl = numOrig.Addressxl
         compare.Add numComp
      End If
   Next numOrig

'''''''''' OTHER PROCEDURES

End Function

EDIT:

I removed a lot of unnecessary code and trying to isolate the issue to to the above code. It seems as though the collection getting passed through into the function is having issues?

Run-time error '13':

Type mismatch

Upvotes: 0

Views: 680

Answers (1)

Mathieu Guindon
Mathieu Guindon

Reputation: 71237

The Debug.Print statement is trying to convert CASN.Addressxl to a String, and failing to do that.

Verify the types involved.

Upvotes: 1

Related Questions