VBA to replace/remove

tourless

New Member
Joined
Feb 8, 2007
Messages
43
Hi Folks,

I have a list of customers in column A. All of them start with "zz" which is simple enough to remove using...
Range("A2:A" & lRow).Replace what:="zz", Replacement:="", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=True, _
SearchFormat:=False, ReplaceFormat:=False
In that same list there are a variety of possible ending characters that I would like to remove as well. Some customers end with just their name which is fine. Others might end with "***OOB" or "***PO" or "***QT" or some variety therein. What I would like to do is any time the * character is found, remove it and anything that comes after it. I've tried variations on the following with no luck so far...
Range("A2:A" & lRow).Replace what:="(*)", Replacement:="", LookAt:=xlPart

UPDATE:
This has gotten me closer...
Range("A2:A" & lRow).Replace what:=" ~*", Replacement:="", LookAt:=xlPart

TIA!
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,317
Office Version
365
Platform
Windows
How about
Code:
Range("A2:A" & LRow).Replace "~**", "", xlPart, , False, , False
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
32,317
Office Version
365
Platform
Windows
You're welcome & thanks for the feedback
 

jmacleary

Well-known Member
Joined
Oct 5, 2015
Messages
796
Office Version
2007
Platform
Windows
You need a minor tweak to your code: use Range("A2:A" & lRow).Replace what:=" ~**", Replacement:="", LookAt:=xlPart
 

Forum statistics

Threads
1,082,310
Messages
5,364,428
Members
400,802
Latest member
RichBRich

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top