Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Regex Expression to loop through a column and replace names

Posted on 2013-06-24
4
Medium Priority
?
396 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 93

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 93

Accepted Solution

by:
Patrick Matthews earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

971 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