+ Reply to Thread
Results 1 to 3 of 3

Finding a word and replacing it with a number

  1. #1
    Registered User
    Join Date
    10-29-2011
    Location
    Ldn
    MS-Off Ver
    Excel 2003
    Posts
    5

    Finding a word and replacing it with a number

    Hi,

    So assuming I have a list of sentences in column A. In column B, I now want to enter either the number 1 if the sentence in the same row contains the word "horse" or the number 2 if it doesn't. I can't seem to figure out what formula to use.

    =if(A1="horse", 1, 2)
    But obviously this won't work because the sentence never contains simply the word "horse", It'll have "horses on parade" or stuff like that. vlookup or hlookup won't work either as far as I know.

    How can I get around this?

    Thanks in advance,

    -B

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Finding a word and replacing it with a number

    =IF(ISNUMBER(SEARCH("horse",A1)),1,2)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Registered User
    Join Date
    10-29-2011
    Location
    Ldn
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Finding a word and replacing it with a number

    Amazing! Much appreciated.

+ 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