Solved

Regex Expression to loop through a column and replace names

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS excel check if Links exist 5 36
Excel Need to return the text of a filter column 11 22
locking multiple column ranges 10 26
Assigning VBA code to a specific worksheet 3 26
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

831 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