+ Reply to Thread
Results 1 to 4 of 4

A unknow find error...

Hybrid View

thedryden A unknow find error... 08-25-2006, 06:01 PM
davesexcel lets see more of the code 08-25-2006, 06:06 PM
thedryden Well while this is failing in... 08-25-2006, 06:09 PM
thedryden Ok I've sorted this out. The... 08-25-2006, 06:17 PM
  1. #1
    Registered User
    Join Date
    07-05-2006
    Posts
    16

    A unknow find error...

    I'm running a bit of code to try and find cells that have "Complete" in them in a certain range. In an effort to avoid errors I use an If statement that is [i]supposed[i] go to an exit do if there is no cell with "Complete" in the range. Here's the thing: Whenever I run this bit of code Excel chokes if the if statement is NOT true, I get an error instead of going to the "Else" which is "Exit Do". Can anyone tell me what I'm doing wrong?

    The If statement is as follows (and I need to leave the Range statement “As is” as normally the rows are Variables):

    If Not Worksheets("Joy 2006").Range(Cells(7, 7), Cells(57, 7)).Find("Complete") Is Nothing Then

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    lets see more of the code

  3. #3
    Registered User
    Join Date
    07-05-2006
    Posts
    16
    Quote Originally Posted by davesexcel
    lets see more of the code
    Well while this is failing in a much longer macro, it is also failing in the following "test" macro.

    Sub test()
    Dim intRow As Integer


    If Not Worksheets("Joy 2006").Range(Cells(7, 7), Cells(57, 7)).Find("Complete") Is Nothing Then
    intRow = Worksheets("Joy 2006").Range(Cells(7, 7), Cells(57, 7)).Find("Complete").Row
    End If
    MsgBox (intRow)

    Worksheets("Joy 2006").Range(Cells(7, 7), Cells(41, 7)).Select
    End Sub

  4. #4
    Registered User
    Join Date
    07-05-2006
    Posts
    16
    Ok I've sorted this out. The problem only occured when the active sheet was not "Joy 2006" so I changed the code to the following and now it works:

    Sub test()
    Dim intRow As Integer


    If Not Worksheets("Joy 2006").Range(Worksheets("Joy 2006").Cells(7, 7), Worksheets("Joy 2006").Cells(55, 7)).Find("Complete") Is Nothing Then
    intRow = Worksheets("Joy 2006").Range(Worksheets("Joy 2006").Cells(7, 7), Worksheets("Joy 2006").Cells(57, 7)).Find("Complete").Row
    End If
    MsgBox (intRow)

    End Sub

+ Reply to Thread

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