VBA – Remove Characters from Left or Right Side of Variable Length String

Associated Files Download Links

If you always know the length of a string, it’s easy to remove characters from it. Example: If you have a string that is 10 characters and you want to remove 1 character from the Left side, simply return the right 9 characters:

This doesn’t work for a variable length string, or one which you don’t know beforehand it’s length. In this case you can use the formula (Length – N) to designate how many characters to extract:

Where 1 is the number of characters to remove from the left side of the string. This will return the string minus the left most character.

To remove characters from the right side of a string, replace Right with Left

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

Learn More!

<<Return to VBA Examples

Did you find this VBA tutorial useful? Then share it with your friends and colleagues:

You may also like some of this related content...

VBA has many string functions that will allow you to manipulate and work with text
In VBA, you can compare two strings using the StrComp function. In this tutorial, you
You can perform logic on, or return individual characters from a string in VBA by
Count Number of Words in a String The following VBA function counts the number of
Add Spaces to a String A common way to add spaces to a string with