I have a function that requires a range object as a parameter. When I loop through the cells in a worksheet I pass a cell into the function to get the result I need. When I run it there is an error claiming that I passed a string not a range object. Here is my code:
Dim c As Integer
Dim getRng As Range
Dim Students As StudentCollection 'custom class
Dim Parents As ParentCollection 'custom class
Dim sRng As Range
c = 1
Set getRng = rng.Cells(1, 1)
While getRng <> "end"
While InStr(1, getRng, "Parent") = 0
c = c + 1
Set getRng = rng.Cells(c, 1)
Wend
If InStr(1, getRng, "Parent 1") > 0 Then
Set sRng = getRng.Offset(-5, 0) 'this reads a "sRng.value"
Students.AddCollect (sRng) 'this throws the error claiming sRng is not an object
Parents.AddCollect (getRng)
ElseIf InStr(1, getRng, "Parent 2") > 0 Then
Parents.AddCollect (getRng)
End If
Wend
Students.Send (studentRng)
Parents.Send (parentRng)
Any ideas?
Bookmarks