Find and Replace VBA script for a range with exact match with quotes

Jzaik

New Member
Joined
Jun 26, 2019
Messages
44
Hi there,

I am not familiar with VBA at all. I need to replace a whole set of alpha Xpath values that look like this:

ISOXML/Pmt/CrdtrAgt/CrdtrAgtTp/Nm
ISOXML/CasePmt/Agt/Nm

I have two columns set like this with the quotes to indicate that I want the whole string changed match for match.

Col1 Col 2
"Agt" "4XDD"
"Crdtr" "76ER"
"CrdtrAgt" "YY34"
"Pmt" "UU55"
"CasePmt" "788R"
"Nm" "91TR"

I used this generic script I found online:

Code:
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Sub</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">MultiFindNReplace()</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb comments" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 130, 0) !important;">'Update 20140722</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Dim</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Rng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">As</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Range</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Dim</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">As</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Range, ReplaceRng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">As</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Range</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">xTitleId = </code><code class="vb string" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">"KutoolsforExcel"</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Set</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng = Application.Selection</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Set</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng = Application.InputBox(</code><code class="vb string" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">"Original Range "</code><code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">, xTitleId, InputRng.Address, Type:=8)</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Set</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">ReplaceRng = Application.InputBox(</code><code class="vb string" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">"Replace Range :"</code><code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">, xTitleId, Type:=8)</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Application.ScreenUpdating = </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">False</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">For</code> <code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Each</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Rng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">In</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">ReplaceRng.Columns(1).Cells</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb spaces" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">    </code><code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Next</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Application.ScreenUpdating = </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">True</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">End</code> <code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Sub</code>[/FONT][/COLOR]

The problem with this script is that

ISOXML/Pmt/CrdtrAgt/CrdtrAgtTp/Nm
ISOXML/CasePmt/Agt/Nm

Will be converted partly like

ISOXML/UU55/Crdtr4XDD/Crdtr4XDDTp/91TR
ISOXML/CaseUU55/4XDD/91TR


So I tried to modify the script like this:
Code:
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Sub</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">MultiFindNReplace()</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb comments" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 130, 0) !important;">'Update 20140722</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Dim</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Rng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">As</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Range</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Dim</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">As</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Range, ReplaceRng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">As</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Range</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">xTitleId = </code><code class="vb string" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">"KutoolsforExcel"</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Set</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng = Application.Selection</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Set</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">InputRng = Application.InputBox(</code><code class="vb string" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">"Original Range "</code><code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">, xTitleId, InputRng.Address, Type:=8)</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Set</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">ReplaceRng = Application.InputBox(</code><code class="vb string" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 0, 255) !important;">"Replace Range :"</code><code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">, xTitleId, Type:=8)</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Application.ScreenUpdating = </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">False</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">For</code> <code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Each</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Rng </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">In</code> <code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">ReplaceRng.Columns(1).Cells</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb spaces" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">    </code>[B]InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value & ""[/B][/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Next</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb plain" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-size: 1em !important; min-height: auto !important;">Application.ScreenUpdating = </code><code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">True</code>[/FONT][/COLOR]
[COLOR=#000000][FONT=Consolas]<code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">End</code> <code class="vb keyword" style="border-radius: 0px !important; background: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; font-weight: bold !important; font-size: 1em !important; min-height: auto !important; color: rgb(0, 102, 153) !important;">Sub</code>[/FONT][/COLOR]

That doesn't seem to work.

If anyone knows a solution for this, it would be appreciated. Thanks.
 
I edited the code as your instructions, but it still doesn't like this portion in bold below. It's saying that it's a Type Mismatch.
Code:
Sub Replace_Items()

    Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual


Dim FindN_Replace_Array() As Variant, X As Long, element As Variant, Column_B() As Variant, T As Long, Y As Long, _
    Item As Variant, My_C As New Dictionary, New_String As String, String_Match() As Variant, Choice As Boolean


    FindN_Replace_Array = ActiveSheet.Range("A1:C" & ActiveSheet.UsedRange.Rows.Count).value2 'from the top row ro the last used row in columns A & C


    Column_B = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 2) 'column 2 of the Array


    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1)


        For Y = 2 To 3 ' 2 and 3 correspond to the array column holding the items being searched for and their replacement


            FindN_Replace_Array(X, Y) = Replace(FindN_Replace_Array(X, Y), Chr(34), vbNullString) 'removes quotation marks from all items
            FindN_Replace_Array(X, Y) = Trim(FindN_Replace_Array(X, Y)) 'removes leading and trailing spaces from all items


        Next Y


    Next X


    If MsgBox("Do you want to replace all possible substring matches that are not [A],[A/],[/A/] or [/A]", vbYesNo, "Replacement Type") _
            = vbYes Then Choice = True


    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1) 'top to bottom


        My_C.Add X, Split(FindN_Replace_Array(X, 1), "/")  'Column A is split with "/" and each item is added to an array


        For Each element In Column_B


            On Error GoTo Skip


            T = Application.WorksheetFunction.Match(element, Column_B, 0)
            'location of the replacement row within column C if it exists
            String_Match = My_C.Item(X)


            For Y = 0 To UBound(String_Match)
                'looks for exact matches for A[not part of substrings], A/ , /A/ , /A
                If String_Match(Y) = element Then String_Match(Y) = Replace(String_Match(Y), FindN_Replace_Array(T, 3))


            Next Y
            
            New_String = Join(String_Match, "/") 'joins the array back together again with a "/"
            
Skip: err.Clear


        Next element


        FindN_Replace_Array(X, 1) = New_String


        If Choice = True Then
        
            For Each Item In Column_B
            
                On Error GoTo Skip_2
                
                T = Application.WorksheetFunction.Match(Item, Column_B, 0)


                New_String = Replace(FindN_Replace_Array(X, 1), Item, FindN_Replace_Array(T, 3))
Skip_2: err.Clear
            
            Next Item


        End If


    Next X


    ActiveSheet.Range("A1:A" & ActiveSheet.UsedRange.Rows.Count).value2 = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 1)


    Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic


End Sub
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I deleted this portion: My_C As New Dictionary,

ran it and this portion is saying "argument is not optional"

Code:
If String_Match(Y) = element Then String_Match(Y) = [B]Replace[/B](String_Match(Y), FindN_Replace_Array(T, 3))
 
Upvote 0
I deleted this portion: My_C As New Dictionary,

ran it and this portion is saying "argument is not optional"

Code:
If String_Match(Y) = element Then String_Match(Y) = [B]Replace[/B](String_Match(Y), FindN_Replace_Array(T, 3))
I tested it this time :D
Code:
Sub Replace_Items()


    Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual


Dim FindN_Replace_Array() As Variant, X As Long, element As Variant, Column_B() As Variant, T As Long, Y As Long, _
    Item As Variant, New_String As String, String_Match As Variant, Choice As Boolean


    FindN_Replace_Array = ActiveSheet.Range("A1:C" & ActiveSheet.UsedRange.Rows.Count).value2 'from the top row ro the last used row in columns A & C


    Column_B = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 2) 'column 2 of the Array


    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1)


        For Y = 2 To 3 ' 2 and 3 correspond to the array column holding the items being searched for and their replacement


            FindN_Replace_Array(X, Y) = Replace(FindN_Replace_Array(X, Y), Chr(34), vbNullString) 'removes quotation marks from all items
            FindN_Replace_Array(X, Y) = Trim(FindN_Replace_Array(X, Y)) 'removes leading and trailing spaces from all items


        Next Y


    Next X


    If MsgBox("Do you want to replace all possible substring matches that are not an exact match for [A], or a partial match for:  [A/],[/A/] or [/A]", vbYesNo, "Replacement Type") _
            = vbYes Then Choice = True


    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1) 'top to bottom
        
        String_Match = Split(FindN_Replace_Array(X, 1), "/")
        
        For Each element In Column_B


            If IsEmpty(element) = False Then
            
                T = Application.WorksheetFunction.Match(element, Column_B, 0) 'location of the replacement row within column C if it exists
            
                For Y = LBound(String_Match) To UBound(String_Match)
                    'looks for exact matches for A[not part of substrings], A/ , /A/ , /A
                    If String_Match(Y) = element Then String_Match(Y) = Replace(String_Match(Y), element, FindN_Replace_Array(T, 3))
    
                    If Choice = True Then 'replaces every substring match


                        String_Match(Y) = Replace(String_Match(Y), element, FindN_Replace_Array(T, 3))
            
                    End If
                
                Next Y
                
             End If


        Next element


        FindN_Replace_Array(X, 1) = Join(String_Match, "/")


    Next X


    ActiveSheet.Range("A1:A" & ActiveSheet.UsedRange.Rows.Count).value2 = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 1)


    Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic


End Sub
 
Last edited:
Upvote 0
That one took a little longer, but still executed. But it didn't work completely. And I can't determine a pattern. It looks like it's finding a replacing a few snippets. but then combining values too.

100001/10073/ScrVldtn1038Tm
200002/10090104/1041/1080/116SubDvsn

I'm not sure if I understood the msg box prompt and that's what caused this. If I'm reading this correctly, then I do NOT want to replace all possible matches, just exact matches. So 'ClrSysMmbId' should have a value of '113' and "Id" should have a value of "1047"

"Do you want to replace all possible substring matches that are not an exact match for [A], or a partial match for: [A/],[/A/] or [/A]", vbYesNo, "Replacement Type") _
= vbYes Then Choice = True
 
Upvote 0
Okay, this time I hit 'NO' on the Msg Box prompt. It executed in about 90 seconds. This looks like it worked thoroughly. The only issue I can see is that any value that was by itself with no / was pushed to the right. And that's a non-issue.

[TABLE="width: 403"]
<colgroup><col></colgroup><tbody>[TR]
[TD="align: right"]400004[/TD]
[/TR]
[TR]
[TD]400004/10012[/TD]
[/TR]
[TR]
[TD]400004/10012/1047[/TD]
[/TR]
[TR]
[TD]400004/10012/1007[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141/1063[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141/1080[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141/1080/103

I'll do a double check to see if the values are exact, but I'm sure they are. [/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Okay, this time I hit 'NO' on the Msg Box prompt. It executed in about 90 seconds. This looks like it worked thoroughly. The only issue I can see is that any value that was by itself with no / was pushed to the right. And that's a non-issue.

[TABLE="width: 403"]
<tbody>[TR]
[TD="align: right"]400004[/TD]
[/TR]
[TR]
[TD]400004/10012[/TD]
[/TR]
[TR]
[TD]400004/10012/1047[/TD]
[/TR]
[TR]
[TD]400004/10012/1007[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141/1063[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141/1080[/TD]
[/TR]
[TR]
[TD]400004/10012/1007/141/1080/103

I'll do a double check to see if the values are exact, but I'm sure they are.[/TD]
[/TR]
</tbody>[/TABLE]
I wasn't sure if you wanted to replace substrings of substrings for example:
If the original string is XXX/YXX/Y and you had a replacement for Y as BBB would you still want to replace YXX with BBBXX?

This one might address the speed issue.:
Code:
Sub Replace_Items()


    Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual


Dim FindN_Replace_Array() As Variant, X As Long, element As Variant, Column_B() As Variant, T As Long, Y As Long, _
Column_B_C() As Variant, Item As Variant, New_String As String, String_Match As Variant, Choice As Boolean, Column_B_Dictionary As New Dictionary


With ActiveSheet
    
    T = .Cells(.Rows.Count, "A").End(xlUp).Row
    
    FindN_Replace_Array = .Range("A1:A" & T).value2 'from the top row ro the last used row in columns A & C
    
    T = .Cells(.Rows.Count, "B").End(xlUp).Row
    
    Column_B_C = .Range("B1:C" & T).value2


End With


    Column_B_Dictionary = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 2) 'column 2 of the Array
    
    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1)


        For Y = 1 To 2 ' 1 and 2 correspond to the array column holding the items being searched for and their replacement


            Column_B_C(X, Y) = Replace(Column_B_C(X, Y), Chr(34), vbNullString) 'removes quotation marks from all items
            Column_B_C(X, Y) = Trim(Column_B_C(X, Y)) 'removes leading and trailing spaces from all items


        Next Y


    Next X
        
    For X = LBound(Column_B_C, 1) To UBound(Column_B_C, 1)
    
        Column_B_Dictionary.Add Column_B_C(X, 1), Column_B_C(X, 2)
        
        'items in B are used as a key while Column C is their item
        
    Next X


    If MsgBox("Do you want to replace all possible substring matches that are not do you want to remove matches that are possibly part of another searchable substring", vbYesNo, "Replacement Type") _
            = vbYes Then Choice = True


    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1) 'top to bottom
        
        String_Match = Split(FindN_Replace_Array(X, 1), "/") 'creates delimited array
        
        For Each element In String_Match
  
                'T = Application.WorksheetFunction.Match(element, Column_B, 0) 'location of the replacement row within column C if it exists
            If My_Dictioanry.Exists(element) Then
            
                For Y = LBound(String_Match) To UBound(String_Match)
                
                    'looks for {EXACT matches} for the array element
                    
                    If String_Match(Y) = element Then String_Match(Y) = Replace(String_Match(Y), element, Column_B_Dictionary.Item(element))
    
                    If Choice = True Then 'replaces every substring match within the substring


                        String_Match(Y) = Replace(String_Match(Y), element, Column_B_Dictionary.Item(element))
            
                    End If
                
                Next Y
                
            End If
            
        Next element


        FindN_Replace_Array(X, 1) = Join(String_Match, "/")


    Next X


    ActiveSheet.Range("A1:A" & ActiveSheet.UsedRange.Rows.Count).value2 = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 1)


    Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic


End Sub
 
Last edited:
Upvote 0
If the original string is XXX/YXX/Y and you had a replacement for Y as BBB would you still want to replace YXX with BBBXX?

I don't think I'll ever need that functionality, but that could be helpful in the future. I'm still debating as to what my replacement values will be. But I'm fairly confident that it's going to be exact match for match.

I'll try the faster code.
 
Upvote 0
I wasn't sure if you wanted to replace substrings of substrings for example:
If the original string is XXX/YXX/Y and you had a replacement for Y as BBB would you still want to replace YXX with BBBXX?

This one might address the speed issue.:
made a typo:
Code:
Sub Replace_Items()


    Application.ScreenUpdating = False: Application.Calculation = xlCalculationManual


Dim FindN_Replace_Array() As Variant, X As Long, element As Variant, Column_B() As Variant, T As Long, Y As Long, _
Column_B_C() As Variant, Item As Variant, New_String As String, String_Match As Variant, Choice As Boolean, Column_B_Dictionary As New Dictionary


With ActiveSheet
    
    T = .Cells(.Rows.Count, "A").End(xlUp).Row
    
    FindN_Replace_Array = .Range("A1:A" & T).value2 'from the top row ro the last used row in columns A & C
    
    T = .Cells(.Rows.Count, "B").End(xlUp).Row
    
    Column_B_C = .Range("B1:C" & T).value2


End With


    Column_B_Dictionary = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 2) 'column 2 of the Array
    
    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1)


        For Y = 1 To 2 ' 1 and 2 correspond to the array column holding the items being searched for and their replacement


            Column_B_C(X, Y) = Replace(Column_B_C(X, Y), Chr(34), vbNullString) 'removes quotation marks from all items
            Column_B_C(X, Y) = Trim(Column_B_C(X, Y)) 'removes leading and trailing spaces from all items


        Next Y


    Next X
        
    For X = LBound(Column_B_C, 1) To UBound(Column_B_C, 1)
    
        Column_B_Dictionary.Add Column_B_C(X, 1), Column_B_C(X, 2)
        
        'items in B are used as a key while Column C is their item
        
    Next X


    If MsgBox("Do you want to replace all possible substring matches that are not do you want to remove matches that are possibly part of another searchable substring", vbYesNo, "Replacement Type") _
            = vbYes Then Choice = True


    For X = LBound(FindN_Replace_Array, 1) To UBound(FindN_Replace_Array, 1) 'top to bottom
        
        String_Match = Split(FindN_Replace_Array(X, 1), "/") 'creates delimited array
        
        For Each element In String_Match
  
                'T = Application.WorksheetFunction.Match(element, Column_B, 0) 'location of the replacement row within column C if it exists
            
            For Y = LBound(String_Match) To UBound(String_Match)
                
                If Column_B_Dictionary.Exists(String_Match(Y)) Then
                
                    'looks for {EXACT matches} for the array element
                    
                    String_Match(Y) = Column_B_Dictionary.Item(element)
    
                    If Choice = True Then 'replaces every substring match within the substring
                        
                        For T = LBound(String_Match) To UBound(String_Match)
                            
                            String_Match(T) = Replace(String_Match(T), element, Column_B_Dictionary.Item(element))
                        
                        Next T
                    
                    End If
              
                End If
                
            Next Y
                          
        Next element


        FindN_Replace_Array(X, 1) = Join(String_Match, "/")


    Next X


    ActiveSheet.Range("A1:A" & ActiveSheet.UsedRange.Rows.Count).value2 = Application.WorksheetFunction.Index(FindN_Replace_Array, 0, 1)


    Application.ScreenUpdating = True: Application.Calculation = xlCalculationAutomatic


End Sub
 
Last edited:
Upvote 0
On a separate topic, is there an easy way to run this trim/clean formula for an entire sheet? I usually just do it by columns and fill down, then copy values and paste values. Which is fine and I don't mind doing that but if there's a way to do that for multiple columns, that would be faster.

Code:
=TRIM(CLEAN(H1))
 
Upvote 0
On a separate topic, is there an easy way to run this trim/clean formula for an entire sheet? I usually just do it by columns and fill down, then copy values and paste values. Which is fine and I don't mind doing that but if there's a way to do that for multiple columns, that would be faster.

Code:
=TRIM(CLEAN(H1))
This will do that for every cell in the usedrange for the activesheet
Code:
Sub Trim()


Dim AR() As Variant, X As Long, Y As Long


AR = ActiveSheet.UsedRange

For X = LBound(Trim, 1) To UBound(Trim, 1)
    
    For Y = LBound(Trim, 2) To UBound(Trim, 2)
    
        AR(X, Y) = Trim(AR(X, Y))
        
    Next Y
    
Next X
    
ActiveSheet.UsedRange = AR


End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top