Results 1 to 1 of 1

Cells.Find if it doesn't find?

Threaded View

  1. #1
    Registered User
    Join Date
    11-17-2004
    Posts
    20

    Cells.Find if it doesn't find?

    I have a Cells.Find(What:="Text1", etc) in the middle of a macro to set a variable to the ActiveCell. If this does not find Text1, how to i complete the following to display message box and exit the sub, otherwise continue with the sub.....

    Dim Old as Long
    Dim rngFind As Range

    rngFind = Cells.Find(What:="Text1", After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False).Activate

    If rngFind = Nothing Then
    -display message box: Text1 Not Found, Ending Macro Now
    -Exit Sub

    End IF

    Old = ActiveCell.Row
    rest of sub... blah blah

    End Sub

    I'm close but still learning...
    ----------

    As it turns out... The message box and the Exit Sub are easy... But I'm really lost on how to write the IF THEN if Text1 not found
    Last edited by gradientS; 02-24-2005 at 05:18 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