I am having a bit of trouble coming up with a working vba code to move letters back in a string with some constraints and I would appreciate some help
String KEY has fixes size of letters ie "ABCDEFGHIJ"
There is another string LOCK that contains letters that are imovable in the string KEY. ie "AC"
Finally I have the Letter string that contains the letter that is moving ie "J"
What I am doing is that I am moving the Letter up the key string and once it reaches the end of it it goes back to the begining of the KEY string ie to position 1.
It could be done with a simple code Result=right(KEY,len(key)-1) & LETTER
The problem is that the LOCK string contains letters that are immovable in the KEY string, which means that the letters A will always occupy the 1st spot in the Key string and C the third.
so for ie when trying to move J to the beginning of the string the result instead of being "JABCDEFGHI" should be "AJCDEFGHI"
if the LOCK string was "AB" then the result would be "ABJCDEFGHI"
if LOCK was "BC" then the solution is JBCADEFGH"
Any help would be appreciated with some code to achieve this.
Bookmarks