Reputation: 133
I have had a a hard time dealing with error 438. I am trying to save the property of salary to each and every employee in the collection.
Public Sub Click()
Dim employee As Collection
Set employee = New Collection
Dim n As Integer
Dim i As Integer
Dim E1 As Variant
Dim j As Integer
n = 528
Dim t As String
For i = 3 To n
t = "T" + CStr(i)
Set E1 = New clsEmployee
E1.salary = Sheets("A").Range(t).Value
Next i
End sub
Upvotes: 0
Views: 1021
Reputation: 22205
The only way I can conceivably see getting that specific runtime error with the posted code is if clsEmployee
does not have a public .salary
property. This can be confirmed by changing the declaration from...
Dim E1 As Variant
...to:
Dim E1 As clsEmployee
In this case it will give a compile error "Method or data member not found" instead of a runtime error.
The solution is to add the property if it doesn't exist or make it public if it does.
Upvotes: 1