Results 1 to 2 of 2

Range input parameter reads as value not object

Threaded View

  1. #1
    Registered User
    Join Date
    05-18-2010
    Location
    Utah, USA
    MS-Off Ver
    Excel 2007
    Posts
    1

    Range input parameter reads as value not object

    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?
    Last edited by Leith Ross; 05-18-2010 at 03:15 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1