+ Reply to Thread
Results 1 to 4 of 4

If find is true then.....

  1. #1
    Registered User
    Join Date
    06-01-2005
    Posts
    13

    If find is true then.....

    Hey everyone, quick question. Im looking to have some code that will first try to find a value on a page. If it can't find that value, then it does a set of actions, otherwise, it does a different set of actions. At first I thought to use an If, then, else statement, but I don't really know how to incorporate the Find condition. If I could get some help that'd be great. thanks!!!

  2. #2
    Registered User
    Join Date
    06-01-2005
    Posts
    13
    bump bump

  3. #3
    Forum Contributor
    Join Date
    11-09-2004
    Posts
    451
    Sub macro()
    On Error Resume Next
    Cells.Find("test").Address
    If Err.Description <> "" Then ' did not find the text
    'your code
    Else 'found the text
    'your code
    End If

    End Sub

  4. #4
    Tom Ogilvy
    Guest

    Re: If find is true then.....

    Dim rng as Range
    Dim sTarget as String

    sTarget = "ABCDE"
    set rng =Cells.Find(What:=sTarget, _
    After:=ActiveCell, _
    LookIn:=xlFormulas, _
    LookAt:=xlPart, _
    SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    if not rng is nothing then
    msgbox "found in cell " & rng.Address
    Else
    msgbox "Not found"
    End Sub


    --
    Regards,
    Tom Ogilvy


    "jpizzle" <jpizzle.1rc861_1119964140.2179@excelforum-nospam.com> wrote in
    message news:jpizzle.1rc861_1119964140.2179@excelforum-nospam.com...
    >
    > Hey everyone, quick question. Im looking to have some code that will
    > first try to find a value on a page. If it can't find that value, then
    > it does a set of actions, otherwise, it does a different set of actions.
    > At first I thought to use an If, then, else statement, but I don't
    > really know how to incorporate the Find condition. If I could get some
    > help that'd be great. thanks!!!
    >
    >
    > --
    > jpizzle
    > ------------------------------------------------------------------------
    > jpizzle's Profile:

    http://www.excelforum.com/member.php...o&userid=23920
    > View this thread: http://www.excelforum.com/showthread...hreadid=382771
    >




+ 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