View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Domenic
 
Posts: n/a
Default Matching Text with With Certain Criteria

In article ,
SteveC wrote:

Domenic, a true work of art! Thank you.


You're very welcome! Although part of the credit should go to Max. I
started to go in a slightly different direction until I saw his
solution. :)

Not to mar your elegant work with a beginner's learning, but: Assuming the
primary exchange is in Cell B1, all exchanges are in Cell G1, I modified the
formula to return the Primary Exchange if it Doesn't find a U.S. Exchange in
Cell G1:

=IF(ISERROR(MID(G1,LOOKUP(BigNum,FIND(List,G1)),FI ND(",",G1&",",LOOKUP(BigNum,
FIND(List,G1)))-LOOKUP(BigNum,FIND(List,G1)))),B1,(MID(G1,LOOKUP(B igNum,FIND(L
ist,G1)),FIND(",",G1&",",LOOKUP(BigNum,FIND(List,G 1)))-LOOKUP(BigNum,FIND(List
,G1)))))


=IF(OR(ISNUMBER(FIND(List,C2))),MID(C2,LOOKUP(BigN um,FIND(List,C2)),FIND(
",",C2&",",LOOKUP(BigNum,FIND(List,C2)))-LOOKUP(BigNum,FIND(List,C2))),B2
)

....confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Please tell me, what is the logic of assigning BigNum with all of this? I
don't understand the logic of the formula.


BigNum, which we've defined as 9.99999999999999E+307, is the largest
number recognized by Excel. When used as a lookup value for the LOOKUP
function, the last value in the lookup array is returned. For
additional information, see the following link...

http://www.mrexcel.com/board2/viewtopic.php?t=105725

Out of simple curiosity, I wonder if there is a way to prioritize the search.
So for example, by priority:

1) NYSE
2) AMEX
3) NasdaqNM
4) NasdaqSM

If there is more than U.S Exchange listed, it will return by priority. For
example, if there is a NYSE and NasdaqNM string present, it will return the
NYSE string (priority 1 versus priority 3).

If there is a NasdaqNM and NasdaqSM string, it will return the NasdaqNM
string (priority 3 versus priority 4).


Simply reverse the order of the list entered in Z2:Z5...

NasdaqSM:
NasdaqNM:
AMEX:
NYSE:

Hope this helps!