Solved

Regex Expression to loop through a column and replace names

Posted on 2013-06-24
4
355 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now