If I declare a string outside of a sub I can use it within any sub. If I change the value within the sub then that's fine, unless I make it equal to another String which was declared within that sub. If I do that, the value of the first string becomes blank as soon as the sub ends.
This is kind of hard to explain, so see this example:
dim testglobal as string
testglobal = "global"
dim testlocal as string
testlocal = "local"
testglobal = testlocal
The output from this is:
During the sub the value of testglobal is "local". Once the sub ends, it becomes blank.
I think I would be better off using a function for this kind of thing rather than a sub, but I just thought it was worth checking whether that behaviour was expected or not.