Solved

Data Cleansing - Text Manipulation - VBA Code

Posted on 2010-11-09
3
685 Views
Last Modified: 2012-08-13
Hello experts,

I'm looking for VBA code that would remove the text between brackets, including the brackets, so the line:
COTY: CK/ DAVIDOFF: SEQUEL SATURDAYS:  THE BOURNE IDENTITY (2002, PG-13, 119 min,*3/3)
should become:
COTY: CK/ DAVIDOFF: SEQUEL SATURDAYS:  THE BOURNE IDENTITY

The above operation should be applied on every line in a movie list that is supplied in an Excel sheet. Please see below sample of that list:

COTY: CK/ DAVIDOFF: SEQUEL SATURDAYS:  THE BOURNE IDENTITY (2002, PG-13, 119 min,*3/3)
RENAULT: SEQUEL SATURDAYS:  THE BOURNE SUPREMACY (2004, PG-13, 108 min,*1/3)
PETROMIN: THE LAST KING OF SCOTLAND (2006, R, 123 min, +2)
KFC: CONSPIRACY (2008, R, 90 min, 2/4)
WOLF CREEK (2005, R, 99 min, 4/4)
THE SILENCE OF THE LAMBS (1991, R,118 min, *3/4)
JOY RIDE (2001, 97 min,*3/4)
FORD: MONDAY NIGHT PREMIERE: THE HITCHER (2007, R, 84 min, 1/4)
THE TEXAS CHAINSAW MASSACRE (2003, R, 98 min, 6/6)
POWER HORSE: DOOM (2005, R, 100 min, +2)
SNICKERS: HOME OF MOVIES: THE BOOK OF ELI (2010, R, 118 min, 1/6)
RAMBO IV (2008, R, 92 min,*1/99)
KIA: DARK BLUE (2002, R, 118 min,*4/4)
STC: 16 BLOCKS (2006, 105 min, *1/4)
ADIDAS: NAKED WEAPON (2002, R, 92 min, *1/99)
WRIGLEYS: TORNADO! (1996, PG, 89 min,1/3)
STC:  DOMINO (2005, R, 127 min,5/99)
GRAND CHEROKEE: CHILLER: HOSTEL (2005, R, 94 min, 1/3)
CREEP (2004, R, 85 min,*1/99)
PETROMIN: THE MANCHURIAN CANDIDATE (2004, R, 129 min,*1/4)
SLITHER (2006, R, 95 min, *1/6)

I'm also attaching a sample Excel sheet for your reference.

The VBA code should read line by line and remove the entire part between brackets, which is the release year of the movie, Rating, Duration, etc..)

The good news is that you will only have one left "(" and one right ")" brackets, so your code should be straightforward in trying to locate the position of those brackets in the entire string and simply do a replace or any other text manipulating function to remove it.

Also, the list is in one column, so I can select the colum, and then run the code with :


For each cell in Selection
.....
Replace ....
....
next cell

End sub


Appreciate your help
 Movie-List.xlsx
0
Comment
Question by:Mehawitchi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
broomee9 earned 500 total points
ID: 34093247
No need for a loop.  Try this:

Option Explicit

Sub RemoveParens()
    Columns("A:A").Replace What:="(*)", Replacement:="", LookAt:=xlPart
End Sub

Open in new window

Example.xlsm
0
 

Author Comment

by:Mehawitchi
ID: 34093273
WOW - That was absolutely amazing
0
 
LVL 24

Expert Comment

by:broomee9
ID: 34093290
Thanks for the grade!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question