Hello,
I'm reasonably trained in VBA code but I can't get this one to work.
ToTrim is a long range wit too long strings that I want to shorten.
It contains 19 reappearing substrings (some with a * wildcard) that I want to cut out and replace by some much shorter string or nothing at all.
ReplacTab is a 2-columntable M1:N19 with the annoying substrings in the left column and the replacementes in the right. Looks like this :
So why does the code below give me the finger? No error messages either.
Thank you very much for any suggestion!
Gratefully,
Herman Van Noten
I'm reasonably trained in VBA code but I can't get this one to work.
ToTrim is a long range wit too long strings that I want to shorten.
It contains 19 reappearing substrings (some with a * wildcard) that I want to cut out and replace by some much shorter string or nothing at all.
ReplacTab is a 2-columntable M1:N19 with the annoying substrings in the left column and the replacementes in the right. Looks like this :
So why does the code below give me the finger? No error messages either.
Thank you very much for any suggestion!
VBA Code:
Sub Replacer()
Dim c As Range, ToTrim As Range, ReplacTab As Range
Set ToTrim = Sheets("Replac").[J2:J1000]
Set ReplacTab = ActiveWorkbook.Sheets("VasteData").[M1:N19]
For Each c In ReplacTab.Columns(1)
ToTrim.Replace What:=c.Value, Replacement:=c.Offset(0, 1).Value, LookAt:=xlPart, SearchOrder:=xlByColumns, MatchCase _
:=False, SearchFormat:=False, ReplaceFormat:=False, FormulaVersion:=xlReplaceFormula2
Next c
End Sub
Herman Van Noten
Attachments
Last edited by a moderator: