1

I checked other similar questions but most of the time it was a "set" which was forgotten. I don't think i forgot one so that's why i'm asking.

I have this module :

Option Explicit
Option Base 0

Public AssetFamilyCollection As New Collection
Public AssetCollection As New Collection


Sub test_demarrage()

    Dim wsTest As Worksheet
    Dim paf As ProcessAssetFamily
    Dim fmly As AssetFamily
    Dim i As Integer

    Set wsTest = ThisWorkbook.Worksheets("test")

    Set AssetFamilyCollection = CreateAssetFamilyCollection()
    Set AssetCollection = CreateAssetCollection()
    Set paf = New ProcessAssetFamily
    Set paf.AssetFamilyCollection = AssetFamilyCollection
    paf.DefaultValue
    paf.CountAssetByFamily (AssetCollection)

End Sub

The error is one the line paf.CountAssetByFamily (AssetCollection)

Here is the code of the class ProcessAssetFamily

Option Explicit

Private pAssetFamilyCollection As Collection

'Get Set for the collection of AssetFamily
Public Property Get AssetFamilyCollection() As Collection
    Set AssetFamilyCollection = pAssetFamilyCollection
End Property

Public Property Set AssetFamilyCollection(lAssetFamilyCollection As Collection)
    Set pAssetFamilyCollection = lAssetFamilyCollection
End Property

Public Sub DefaultValue()

    Dim fmly As AssetFamily
    For Each fmly In AssetFamilyCollection
            fmly.checked = False
            fmly.startColumn = 0
    Next fmly

End Sub

Public Sub CountAssetByFamily(CollectionOfAsset As Collection)

    Dim asst As Asset
    Dim fmly As AssetFamily
    Dim sum As Integer

    fmly.numberOfAsset = 0

    For Each fmly In Me

        fmly.numberOfAsset

        For Each asst In CollectionOfAsset
            If asst.familyName = fmly.name Then
                fmly.numberOfAsset = fmly.numberOfAsset + 1
            End If
        Next asst

    Next fmly


End Sub
TmSmth
  • 450
  • 5
  • 31

0 Answers0