English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

for example:
if the sheet contains: CELLA2= "0/ABC/0/ACT/AID/N/2nd", CELLA3= "0/ZYXLQ/0/NRSG/RN/Tx/1st", etc
i want to 'count' the "/" and return the characters between the 4th and 5th "/"
I have tried to use the LEFT/RIGHT/MID functions but with the variable number of characters before & after the one's i am trying to get it meant manually editing the formulas, which is what i am trying to avoid.
for the example above, i would like to have "AID" in CELLB2 and "RN" in CELLB3, etc
If i have been unclear, please tell me what more information i can provide to clarify the matter. I hope this is possible!

2006-12-28 07:30:19 · 1 answers · asked by Act D 4 in Computers & Internet Programming & Design

1 answers

your text is in cell A1 and my formula in cell B1
This formula will return anything between the 4th "/" and 5th "/"

how does it work?
the function substitute can change one character into another one.
So I decide to change the 4th "/" into a "\" and then thanks to the function SEARCH I know where my "\" is in your string of characters.
I do the same with the 5th "/" which I turn to a "\" and retrieve its position thanks to the search function
Knowing the position of the 4th "/" I know where to make the MID function start. Then as I know the position of the 5th "/" I can ask the MID function how many characters to retrieve (5th "/" position - 4th "/" position)

=MID(A1,SEARCH("\",SUBSTITUTE( A1,"/","\",4),1)+1,SEARCH( "\",SUBSTITUTE(A1,"/","\",5)) - (SEARCH( "\",SUBSTITUTE( A1,"/","\",4),1)+1))

NOTE 1: I added some extra spaces between the () to prevent Y Q/A from turning some parts of the formula into "..." When pasting the formula Excel should normally get rid of them. If it is not the case, you'll have to do it yourself.

NOTE 2: It is much easier with a macro. So if you don't bear any grudge against macros, let me know it, (email me through Y Q/A)

2006-12-28 08:31:14 · answer #1 · answered by Anonymous · 1 0

fedest.com, questions and answers