Excel ; Search and Substitute function

Anonymous
2025-01-11T17:13:57+00:00

Hi,
is there a way to deal with partial matches ; so in a cell I have say

'The cattle and the field'

but want to search for or substitute the words cat and dog so

     SEARCH { "cat", "dog"}, "the cattle in the field" )    = 5 , which is not what I'm wanting   

I want it ignored and only "cat" to be looked for.

is there something else I could use

Richard

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Andreas Killer 144.1K Reputation points Volunteer Moderator
2025-01-11T18:54:45+00:00

Richard,

Basically search for " cat ", but that leads to the problem to find it in "I have a cat, you have a dog!". Therefore you have to prepare the sentence, replace all delimiters with a blank, add a blank at the beginning and end. Search for the phrase in there.

Andreas.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2025-01-18T17:48:02+00:00

    Richard,

    Regex is a snail, it's a good way for a few searches if you are not a programmer and/or can not use VBA.

    If you have a lot of rows... better not use it.

    Andreas.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2025-01-18T15:18:03+00:00

    One way is to use the new REGEX , I know this does not give a position but works for
    many scenarios

    so "The cattle in the field'
    "The cat and dog"

    so =REGEXREPLACE(E6,"\dcat\d","TIGER") ; her "\btext\b" here \d isolates the text in the string
    carrot , dollar "^ text string $" will bookend a text string .

    so ; =REGEXTEST("The cattle in the field",{"cat","\bcat\b"}) = TRUE / FALSE

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2025-01-12T16:36:25+00:00

    Yeah, I don't think there is a solution,
    if t just contained one word I did think of

    IF(LEN("cat")=LEN(H4),SUBSTITUTE(H4,"cat","TIGER"),H4)

    but this is not that practical , thanks for taking the time to reply.

    Richard.

    Was this answer helpful?

    0 comments No comments