Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Regex Expression to loop through a column and replace names

Need Excel Regex vba function only please:


Passing a Variable for Column and start cell
example "C2"

SO LET'S SAY :
I have a variable that I'am going to pass  say  
t =  "C2"


01_I then need to loop through each cell in the column C  starting at row 2
02_ Look at 2 different regex expressions.
03_If it finds a similiar match then do a replace.

The values I'am looking for are wildcard searches.

Looking for :

*sunbeam*
and
*Rexal*

Not Case Sentitive

Example:
If the cell contains  "Sunbeam Inc" .....Replace with just "Sunbeam"
If the cell contains  "My Sunbeam" .....Replace with just "Sunbeam"

Example:
If the cell contains  "Rexal Drugs Inc" .....Replace with just "Rexal"
If the cell contains  "Rexal Drugs"       .....Replace with just "Rexal"
If the cell contains  "My Rexal Drugs" .....Replace with just "Rexal"



If this helps to determine where in the column a cells lasy entry may be...Column A will alwasy contains a value...

Thanks
very much
Fordraiders
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

I'm as big a booster of RegExp as anyone else here, but why this specific requirement?  You can accomplish your goal just fine without RegExp...
Avatar of Fordraiders

ASKER

such as ?
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks