You can't really use a formula within VBA code. The formula I posted
can be put into the cell in which you want the text within the
parentheses display. For example, if cell A1 has
This is some (data text) stuff
and B1 has the formula
=MID(A1,FIND("(",A1,1)+1,FIND(")",A1,1)-FIND("(",A1,1)-1)
cell B1 will display
data text
If you don't want to use a formula but would rather use a function
written in VBA, press ALT F11 to open the VBA editor, go to the Insert
menu, and choose Module. In that module, paste the VBA code I
provided. Close the VBA editor to return to Excel.
Now, you can enter
=GetDataText(A1)
in some cell and that cell will display the text within the
parentheses from cell A1.
The formula approach and the VBA approach have the same end result --
the text within the parentheses. Since you posted in the Programming
newsgroup, the presumption is that you want a VBA solution. That's
what I provided. However, since the same thing can be had with a
simple formula without using VBA, I provided that as an alternative.
Pick either the formula solution or the VBA solution. The result is
basically the same.
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)