+ Reply to Thread
Results 1 to 6 of 6

If find = true then.... else.... end if

  1. #1
    Registered User
    Join Date
    04-04-2014
    Location
    Warsaw
    MS-Off Ver
    Excel 2010
    Posts
    97

    If find = true then.... else.... end if

    Hello,
    I've got following problem. I've got selected cells in which I try to find value "cat" if I find one I want from macro to write in cell AC6 "found cat", else left value "not found cat", but something is missing in my code:
    Please Login or Register  to view this content.
    I would really appreciate your help folks.
    Regards

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: If find = true then.... else.... end if

    If you're using vba then i'd use if instr(1,range("ac6").text,"cat")>0 then


    sorry mis read.
    Last edited by nathansav; 05-19-2014 at 05:53 AM.
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: If find = true then.... else.... end if

    Hi
    Try this code sample:
    Sub FindPhrase()
    Dim result
    result = InputBox("Enter phrase to find...")
    Cells.Find(What:=result, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
    xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
    , SearchFormat:=False).Activate
    If Selection.Find(What:=result, After:=ActiveCell, LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate = True Then
    Range("AC6").Value = "found cat"
    Else
    Range("AC6").Value = "not found cat"
    End If
    End Sub

    Good luck
    Tony

  4. #4
    Registered User
    Join Date
    04-04-2014
    Location
    Warsaw
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: If find = true then.... else.... end if

    Nope, it doesn't work, and also I want it to be automatic, without InputBox.

  5. #5
    Registered User
    Join Date
    03-28-2014
    Location
    N. Ireland
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: If find = true then.... else.... end if

    Hi Drrazor,

    It is probably a messy code but it should work if you use it in the This Workbook area to work on change

    Please Login or Register  to view this content.
    Let me know if this is what you are after

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If find = true then.... else.... end if

    Try this:

    Please Login or Register  to view this content.
    Note: If you wanted to use the find method, this is how you would do it

    Please Login or Register  to view this content.
    Final note: I would avoid using selection unless you absolutely had to.
    Last edited by stnkynts; 05-19-2014 at 12:37 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. =IF ( FIND ( xxx gives a #VALUE! so the 'Not True' is not executed
    By Fschou in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-23-2012, 01:18 PM
  2. Look, find, and if true, replace?
    By 2709236 in forum Excel General
    Replies: 5
    Last Post: 05-14-2009, 02:27 PM
  3. Replies: 2
    Last Post: 08-23-2005, 08:05 AM
  4. If find is true then.....
    By jpizzle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2005, 12:05 PM
  5. [SOLVED] VB find (true false)
    By Wildman in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-06-2005, 07:06 AM

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