Results 1 to 5 of 5

Unable to get the FindNext property of the Range Class

Threaded View

  1. #1
    Registered User
    Join Date
    06-03-2009
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    59

    Unable to get the FindNext property of the Range Class

    I keep getting that error when I'm running my macro. When I debug, it points me to the bolded line in the code below.

    The larger macro I'm running this function in runs this function some 101 times without error before this happens.

    The values of the parameters are as follows when it gives me the error:
    Find_Exact("hchen", ws1, "B:B")

    The first parameter is the only one that changes in the previously mentioned running of this function.

    Function Find_Exact(ByVal sText As String, ByRef ws As Worksheet, ByVal sRange As String) As Range
        
        Dim first_addr As Range
        Dim found_addr As Range
        Set first_addr = ws.Range(sRange).Find(sText, LookIn:=xlValues)
        If Not first_addr Is Nothing Then
            If ws.Cells(first_addr.Row, first_addr.Column) = sText Then
                Set Find_Exact = first_addr
            Else
                Do
                    Set found_addr = ws.Range(sRange).FindNext(sText)
                    If Not found_addr Is Nothing Then
                        If ws.Cells(found_addr.Row, found_addr.Column) = sText Then
                            Set Find_Exact = found_addr
                            Exit Do
                        End If
                    End If
                Loop While Not found_addr Is Nothing And found_addr <> first_addr
            End If
        End If
    End Function
    What could possibly be the problem??

    Thanks for the help.
    Last edited by Kaigi; 06-26-2009 at 04:05 PM.

Thread Information

Users Browsing this Thread

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

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