Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get length of text string inside parentheses 1

Status
Not open for further replies.

Bouldergirl

Technical User
May 1, 2009
15
0
0
US
Hello,

I've got a bunch of cells which contain long, variable-length strings of data, and nested inside the string is a set of parentheses.

e.g.: this+isAll&unnecessary" stuff">Idon'tneed>(but this part I need)<followed by&MORE unnecessarySTUFF

So I ONLY want to count the number of characters inside the parentheses (i.e., the function I'm looking for in the above example would count "but this part I need", and would return 20)

The parentheses don't appear in exactly the same place within each cell. I'm thinking that using the "FIND" function will be a part of the solution, or maybe I need to get a VBA module, I don't know. Thanks in advance!

Any suggestions?

Thanks!
-Bouldergirl
 



Hi,

Assuming your text in A1...
[tt]
=FIND(")",A1)-FIND("(",A1)-1
[/tt]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
That will get you the location of the text, but to get the actual text, you need to use MID:

MID( A1,
SEARCH("(", A1, 1)+1,
SEARCH(")", A1, 1)-SEARCH("(", A1, 1)-1
)

Where your data is in A1 (text to search).

SEARCH("(", A1, 1)+1
MID will give you the text starting at the location of the first "(" (location determined using the SEARCH formula + 1 to NOT include the open-parenthesis).

SEARCH(")", A1, 1)-SEARCH("(", A1, 1)-1
MID will give you number of characters through the location of the ")" minus the location of the "(" minus one to NOT include the close-parenthesis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top