Link to home
Create AccountLog in
Avatar of Mehawitchi
Mehawitchi

asked on

Data Cleansing - Text Manipulation - VBA Code

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
ASKER CERTIFIED SOLUTION
Avatar of Tracy
Tracy
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Mehawitchi
Mehawitchi

ASKER

WOW - That was absolutely amazing
Thanks for the grade!