ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   finding occurance of characters (https://www.excelbanter.com/excel-discussion-misc-queries/83524-finding-occurance-characters.html)

[email protected]

finding occurance of characters
 
Hi,

I have the data like the following.

ABAACADAM

I would like to find whther the letter "B" is present in it or not. So,
I used FIND("B",F25) which returned me 2.

but, my objective is to find "B","C","D","W". say for eg, if B is not
present then the letter "C" should be searched and the
occurence/position has to be returned. The order of precedence should
be maintained for the letters to be searched. i.e., if B is not found,
search for C, if not found, search for D and if not found search for W.
if nothing is present I should place 0(zero) in the resultant cell.

Is there any simple solution for this task?

thanks
Easwara


Bob Phillips

finding occurance of characters
 
=MIN(IF(MID(A21,ROW(INDIRECT("1:"&LEN(A21))),1)={" B","C","D","W".},ROW(INDIR
ECT("1:"&LEN(A21)))))

which is an array formula, it should be committed with Ctrl-Shift-Enter, not
just Enter.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

wrote in message
oups.com...
Hi,

I have the data like the following.

ABAACADAM

I would like to find whther the letter "B" is present in it or not. So,
I used FIND("B",F25) which returned me 2.

but, my objective is to find "B","C","D","W". say for eg, if B is not
present then the letter "C" should be searched and the
occurence/position has to be returned. The order of precedence should
be maintained for the letters to be searched. i.e., if B is not found,
search for C, if not found, search for D and if not found search for W.
if nothing is present I should place 0(zero) in the resultant cell.

Is there any simple solution for this task?

thanks
Easwara




Max

finding occurance of characters
 
Another play to try ..

Put in say, G25:
=IF(ISERROR(FIND("B",F25)),IF(ISERROR(FIND("C",F25 )),IF(ISERROR(FIND("D",F25
)),IF(ISERROR(FIND("W",F25)),0,FIND("W",F25)),FIND ("D",F25)),FIND("C",F25)),
FIND("B",F25))
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
wrote in message
oups.com...
Hi,

I have the data like the following.

ABAACADAM

I would like to find whther the letter "B" is present in it or not. So,
I used FIND("B",F25) which returned me 2.

but, my objective is to find "B","C","D","W". say for eg, if B is not
present then the letter "C" should be searched and the
occurence/position has to be returned. The order of precedence should
be maintained for the letters to be searched. i.e., if B is not found,
search for C, if not found, search for D and if not found search for W.
if nothing is present I should place 0(zero) in the resultant cell.

Is there any simple solution for this task?

thanks
Easwara




[email protected]

finding occurance of characters
 
Thanks Bob & Max!! Both solutions works!! :)

You guys Rock!!


Max

finding occurance of characters
 
wrote
Thanks Bob & Max!! Both solutions works!! :)
You guys Rock!!


You're welcome ! Thanks for the feedback

But .. there might be some subtle differences <g
... is the order of precedence check still important?,
re your:
... The order of precedence should
be maintained for the letters to be searched.
i.e., if B is not found, search for C, if not found,
search for D and if not found search for W.
if nothing is present .. place 0 (zero) in the resultant cell.


I tested with, say the data: AWAACADAM
Bob's returns: 2 ("W"),
while mine returns: 5 ("C")

With say: AADAMBMM
Bob's returns: 3 ("D"),
while mine returns: 6 ("B")
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---




All times are GMT +1. The time now is 05:41 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com