Reputation: 3153
Not sure why getting the above error. I have a class module named clsRemit
with code:
Sub clsRemit()
Public vendor As String
Public amount As Long
Public invoices As String
End Sub
Then in my module, I have:
For Each v In dictlist.Keys
If InStr(1, .Cells(q, "B").Value2, v, vbTextCompare) Then
vendor = .Cells(q, "B").Value2
If dict.Exists(vendor) = True Then
Set oVend = dict(vendor)
Else
Set oVend = New clsRemit
dict.Add vendor, oVend
End If
oVend.vendor = vendor 'error here
oVend.invoices = oVend.invoices & vbCrLf & .Cells(q, "F")
oVend.amount = oVend.amount + .Cells(q, "G").Value
End If
Next
Upvotes: 1
Views: 329
Reputation: 71187
oVend.vendor = vendor 'error here
That's a red herring. The real problem is here:
Sub clsRemit() Public vendor As String Public amount As Long Public invoices As String End Sub
Public
(or Private
, for that matter) is illegal in a procedure scope. Remove the procedure scope, the code should compile:
Option Explicit
Public vendor As String
Public amount As Long
Public invoices As String
Upvotes: 2