how to find occurences of a word before or after a specific word in an excel cell

Highlighted
New Contributor

Hello Everyone,

I am facing an issue for some time and I have realised that there is no better place to ask for a solution of it than this place. So, here it goes.

 

suppose there is an address line like " YSR Residency opposite of Vodafone Mobile store" in an excel cell. Now, I am looking for a macro query or and excel formula which, if executed, will tell me whether the word "opposite" appeared before the word "Mobile" or after the word "Mobile". Obviously the result must appear in the adjacent right side cell of the cell in which address is present.

 

Thanks a lot for your help and time.

1 Reply
Highlighted

Hi,

 

As simple variant

=IFERROR(IF(SEARCH("opposite",A1)<SEARCH("mobile",A1), "before", "after"),"no such pair")