-
I have a string that I would like to remove a piece of. I know the Mid function will extract a section out of a string, but I want to do the opposite. I'd like to remove part of a string and keep the rest. Is there a function that does this?
Example:
string="aaabbbcccdddeee"
and I want to remove "bbb"
and end up with:
string="aaacccdddeee"
Or does this have to be done manually using Len, InStr, etc?
-
Here's two ways ...
Code:
x = "aaabbbcccdddeee"
x = Replace(x, "bbb", "")
Debug.Print x
x = "aaabbbcccdddeee"
x = Left(x, 3) & Mid(x, 7)
Debug.Print x
-
Nevermind, didn't know there was "Replace"...
-
In theory you could use this approach too :
Code:
x = "aaabbbcccdddeee"
Mid(x, 4, 3) = ""
Debug.Print x
But the mid statement doesnt like replacing things with 0 length strings. So if you wanted to replace it will something else ...
-
=)
That was enough to get done what I needed to.
Thanks!
~Piz