We help IT Professionals succeed at work.
Get Started

Excel VBA: isolate text in parentheses

LCMSdev asked
Last Modified: 2012-05-09
As part of a VBA macro I'm writing in Excel 2007, I need to split text values that contain parentheses. Starting with the text in the cell, which I'll call CurrentText, I want to generate two more strings: NoParens and InParens. NoParens should be the text minus any substring that was in parentheses (and adjusted for spacing); InParens should be the text that was contained in the parentheses.

Examples might be helpful. Let's say CurrentText = "Some Sample Text (SST)". In this case, NoParens should be "Some Sample Text", and InParens should be "SST".

Or, if CurrentText = "More Sample Text (MST) here", then NoParens should be "More Sample Text here", and InParens should be "MST".

I can't quite figure this one out, and would be very grateful if anyone could lend a hand. Thanks!
Watch Question
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE