Excel - FIND from right to left instead of left to right

Asked By David
20-Nov-09 05:25 PM
I need a formula to parse text that looks something like this to extract the
data contained in parentheses.

FI-SL: Local Posting Periods (GCP1)

I was using the following formula which worked just fine ...

=MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1)

...until I ran into text with another left parentheses to the left of the
data I want to extract.

C FI Copy company code (G/L account) (OBY2)

Unfortunately the FIND function does not provide an option to go from right
to left otherwise this would be easy.  Is there another way to extract OBYA
from the text above via formula that will also work on the earlier example?

Thanks in advance!
Microsoft Excel
(1)
SUBSTITUTE
(1)
TRIM
(1)
FIND
(1)
REPT
(1)
LEFT
(1)
CHAR
(1)
MID
(1)
  Mike H replied to David
20-Nov-09 05:37 PM
David,

Try this

=SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1,"(","*",LEN(A1)-LEN(SUBSTITUTE(A1,"(",""))))),")","")

Mike
  T. Valko replied to David
20-Nov-09 05:43 PM
Is there ever a space in the portion you want to extract?

C FI Copy company code (G/L account) (OB Y2)

--
Biff
Microsoft Excel MVP
  Peo Sjoblom replied to David
20-Nov-09 05:52 PM
One way assuming there cannot be any left parens after the string you want to
parse


=SUBSTITUTE(RIGHT(A1,LEN(A1)-FIND("^^",SUBSTITUTE(A1,"(","^^",LEN(A1)-LEN(SUBSTITUTE(A1,"(",""))))),")","")

--


Regards,


Peo Sjoblom
  Rick Rothstein replied to David
21-Nov-09 10:25 PM
As long as this item in parentheses is always at the end of the text, you
can use this formula...

=SUBSTITUTE(TRIM(RIGHT(SUBSTITUTE(A1,"(",REPT(" ",99)),99)),")","")

--
Rick (MVP - Excel)
  Ron Rosenfeld replied to David
21-Nov-09 11:32 PM
The following formula will extract the rightmost (last) parentheses enclosed
substring.  It will extract this even if there is extraneous data after the
last parentheses.

So it will extract OBY2 from either of these:

C FI Copy company code (G/L account) (OBY2)
C FI Copy company code (G/L account) (OBY2) old number

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1,"(",CHAR(1),
LEN(A1)-LEN(SUBSTITUTE(A1,"(",""))))+1,FIND(")",A1,
FIND(CHAR(1),SUBSTITUTE(A1,"(",CHAR(1),LEN(A1)-
LEN(SUBSTITUTE(A1,"(","")))))-1-FIND(CHAR(1),
SUBSTITUTE(A1,"(",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1,"(","")))))

However, if you there will never be data after the last parentheses, then
Rick's formula is probably more efficient.
--ron
  Rick Rothstein replied to Ron Rosenfeld
22-Nov-09 01:39 AM
Here is a little bit shorter formula to do the same thing (it was built out
of my previously posted formula)...

=LEFT(TRIM(RIGHT(SUBSTITUTE(A1,"(",REPT(" ",99)),99)),FIND(")",
TRIM(RIGHT(SUBSTITUTE(A1,"(",REPT(" ",99)),99)))-1)

--
Rick (MVP - Excel)
  Ron Rosenfeld replied to Rick Rothstein
22-Nov-09 07:26 AM
That's good.

You could also download and install Longre's free morefunc.xll add-in, and use:

=REGEX.MID(A2,"(?<=\()[^)]+(?=\))",-1)

--ron
  David replied to Mike H
23-Nov-09 02:23 PM
That worked perfectly, thanks!  Now I just need to reverse engineer it so I
understand how it works.
Create New Account
help
date from sheet name Excel I'd like to turn a sheet name into a date. Apr28 to 4 / 28 and Apr28-30 to Apr28-30 (as text) TIA and thanks for any ideas. Jim Excel Worksheet Discussions Microsoft Excel (1) Excel (1) SUBSTITUTE (1) DATEVALUE (1) Worksheet (1) Relative (1) Workbook (1) COUNT (1) I am going to abbreviation for a month, as "Jan", "Feb", etc. in A2: = LEFT(RIGHT(A1, LEN(A1)-FIND("]", A1)), 3) next we find out which month number the month is in A3: = MATCH(LEFT(RIGHT(A1, LEN(A1
Convert variable #'s in a gen. format to a # that can be used w / ma Excel I have this data that is pasted to my worksheet: Period: 01 / 23 / 2010 to E29 / 147, etc. Basically, those general formatted #'s converted to a usable / divisable #. Thanks, Steve Excel Worksheet Discussions Microsoft Excel (1) SUBSTITUTE (1) Worksheet (1) ISNUMBER (1) Macro (1) TEXT (1) REPT (1) CHAR (1) One way: = - -TRIM(RIGHT(SUBSTITUTE(A1, " ", REPT(" ", 10)), 10)) One way. . . Assuming the word "Days:" is *always* present. = - -MID(A1
Formula To Split Name Excel I have a list of names in colum B, that I would like to split into column D. Column B Column C Column D Mary A Jones Jones Mary A Excel Miscellaneous Discussions Microsoft Excel (1) SUBSTITUTE (1) LEFT (1) FIND (1) TRIM (1) REPT (1) LEN (1) MID (1) Hi, Put this in column C = RIGHT(B1, LEN(B1
What function to use? Len? Excel I am going to create customer ID - Alphanumeric. I have the whole company names and I was trying to come up with a scheme that I can use an Excel Function to make the process faster. I thought about Len but not sure - Is there it. Such as American Can Company - Result of Function - Ameri125 If this is even possible Excel Worksheet Discussions Microsoft Excel (1) Excel (1) SUBSTITUTE (1) SUMPRODUCT (1) COUNTIF (1) UPPER (1) REPT (1) LEFT (1) Hi, which is the logic behind the numbers if the numbers is
Computed value returning#VALUE Excel I have a computed value = TRIM(MID(SUBSTITUTE(U3, ", ", REPT(" ", 255), 2), FIND(", ", U3)+1, 255)) that pulls the date out of a string of text. In this referenced is also a computed value, so I am wondering if that is the case. Excel Miscellaneous Discussions Microsoft Excel (1) SUBSTITUTE (1) TRIM (1) REPT (1) FIND (1) MID (1) BiffMicrosoft (1) Extracts (1