indi visual
Member
I am trying to replace the dot at a specific point in a string.
It will always be the dot followed by 6 characters and the word "EndSearchMarker".
But all of that might be at the front, middle, or end (so I think the MID function is key).
The code below works, but not what I need it for because it replaces all the dots in the string (when I actually only need the 1 dot replaced with "DotMarker").
''eg
Blah.Blah.Blah.Example.StringEndSearchMarker
to
Blah.Blah.Blah.ExampleDotMarkerStringEndSearchMarker
Could anyone help me with the MID line that achieves this?
Sub Replace_This_Dot_Only()
Dim Cell As Range
For Each Cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
If Cell Like "*.??????EndSearchMarker*" Then
Cell.Replace What:=".", Replacement:="DotMarker"
End If
Next Cell
End Sub
It will always be the dot followed by 6 characters and the word "EndSearchMarker".
But all of that might be at the front, middle, or end (so I think the MID function is key).
The code below works, but not what I need it for because it replaces all the dots in the string (when I actually only need the 1 dot replaced with "DotMarker").
''eg
Blah.Blah.Blah.Example.StringEndSearchMarker
to
Blah.Blah.Blah.ExampleDotMarkerStringEndSearchMarker
Could anyone help me with the MID line that achieves this?
Sub Replace_This_Dot_Only()
Dim Cell As Range
For Each Cell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
If Cell Like "*.??????EndSearchMarker*" Then
Cell.Replace What:=".", Replacement:="DotMarker"
End If
Next Cell
End Sub