+ Reply to Thread
Results 1 to 2 of 2

How to deal with Find when nothing is found

  1. #1
    Mike
    Guest

    How to deal with Find when nothing is found

    I have this in my Sub.

    Cells.Find(what:=LOC, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart,
    SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate

    If the string is not found, it runs an error, giving the user the option to
    debug. How can I have it comeback and say the string was not found and then
    end the sub? Am I making sense? Thanks.

  2. #2
    ben
    Guest

    RE: How to deal with Find when nothing is found

    hi
    dim findnotfind as range
    set findnotfind = Cells.Find(what:=LOC, After:=ActiveCell, LookIn:=xlValues,
    LookAt:=xlPart,
    SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False)
    if findnotfind is nothing then
    msgbox "I'm sorry the value was not found"
    exit sub
    end if


    "Mike" wrote:

    > I have this in my Sub.
    >
    > Cells.Find(what:=LOC, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart,
    > SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False _
    > , SearchFormat:=False).Activate
    >
    > If the string is not found, it runs an error, giving the user the option to
    > debug. How can I have it comeback and say the string was not found and then
    > end the sub? Am I making sense? Thanks.


+ 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