Solved

Regex Expression to loop through a column and replace names

Posted on 2013-06-24
4
393 Views
Last Modified: 2013-07-10
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
0
Comment
Question by:fordraiders
[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
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 39273752
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...
0
 
LVL 3

Author Comment

by:fordraiders
ID: 39282780
such as ?
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 39283125
Why not just use VBA's own Replace function?  It has an optional argument that indicates whether to use case-sensitive match or not.
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 39314397
Thanks
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

617 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