In a first Excel File multiple Cells in Column C contains the address and the name of a company; I want to keep only the company name. For that, I have another Excel file (I'll call it "Dictionary"), which has a particular structure like the following:
Column B : Name that I want to keep.
Column C : Various Patterns of the name, delimited with ";".
Example : B1 = "Sony", C1="Sony Entertainement;Sony Pictures;Playstation"
I need VBA macro reading Dictionary File, then for each pattern (surrounded with anything) replace it with the word I want to keep.
My macro would look like :
Sub MacroClear()
<For each line of my dictionnary>
arrayC = split(<cell C of my line>, ";")
<For i in range arrayC>
Cells.Replace What:="*"&Trim(arrayC(i))&"*", Replacement:=Trim(<cell B of my line>), LookAt:= _
xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
EDIT - UPDATE : I made a capture of my first Dictionary, it'll be easier to understand the structure :
dictionnary http://img11.hostingpics.net/pics/403257dictionnary.png
EDIT - UPDATE 2 : I made a screen cap of a "non-cleaned" file, then the result I want at the end.
Not cleaned : noclean http://img11.hostingpics.net/pics/418501notcleaned.png
Cleaned : clean http://img11.hostingpics.net/pics/221530cleaned.png
PS : I know my macro as it is would analyze all the cells of my worksheet, is it possible "easily" to tell her to ignore column A ?
EDIT - UPDATE 3 : My macro runs well with small dictionaries, but when it grows bigger, my macro doesn't stop running and I have to close excel with Ctrl + Alt + Suppr. :x Is there a way to tell her to stop when reaching a point ?
For example, using xlByRows
and writing "END" at the first cell after my last row.