mcomp72
Active Member
- Joined
- Aug 14, 2016
- Messages
- 275
- Office Version
- 365
- 2019
- 2016
- 2011
- Platform
- Windows
- MacOS
I need to remove part of a string with VBA code. The string will never be the same, so I have to treat it as variable. I know how to determine the starting position and the ending position within the string that I want to delete, but can't figure out how to do it. I've searched via Google but there doesn't seem to be an easy way to do it. I assume I need to use the Left, Right, and Replace methods together somehow, but I can't figure out the correct way.
For instance, let's say I have this string: "This is my string. It is very nice. Now let's each lunch."
And I need to change it to: "This is my lunch."
The position within the string where I want the deletion to start is 12.
The position within the string where I want the deletion to end is 54.
How would I delete everything in the string between position 12 and 54?
For instance, let's say I have this string: "This is my string. It is very nice. Now let's each lunch."
And I need to change it to: "This is my lunch."
The position within the string where I want the deletion to start is 12.
The position within the string where I want the deletion to end is 54.
How would I delete everything in the string between position 12 and 54?