Hello All,
I'm in the process of creating a Class (cCampaign) which contains various properties. I've done some simple ones without issue and tested successfully. However, I'm trying to create an additional property that will return an array of Row numbers (generated by searching for the cCampaign object name stored within a Collection Class (called cCampaigns). I've written the code below but it returns a 'Type Mismatch' error. I thought it should be simple to spot but can't see the error in my ways. I would greatly appreciate advice and/or solutions to this problem.
As ever, your patience with my lack of experience is welcomed!
Private pRowNums() As Long
Public Property Get RowNums() As Long
Dim pplSheet As String
Dim Campaigns As cCampaigns
pplSheet = "TEST - DO NOT UPDATE (2)"
For Each c In Worksheets(pplSheet).Range("A1:A" & getNextEmptyRow(pplSheet)).Cells
For i = 1 To Campaigns.Count
If c.value = Campaigns.Item(i).Name Then
ReDim Preserve pRowNums(UBound(pRowNums) + 1)
pRowNums(UBound(pRowNums)) = c.Row
End If
Next i
Next c
RowNums = pRowNums
End Property
In the standard module, my intended code will be something like as follows:
For Each campaign In Campaigns
For i = 1 To UBound(campaign.RowNums)
If Range("A" & RowNum(i)) = campaign.Name Then
X = X + 1
End If
Next i
Next campaign
Bookmarks