I don't know of any specific explanation of this. It's just the way strings
work. They compare the characters in the string, starting from the left,
putting everything into "alphabetical" order. The test is based on the ASCII
sequence of characters and the digits are in that sequence too. If you look for
ASCII collating sequence you should find the order of characters in the ASCII
set.
You have made your variables into integers but you are still using a string -
specifically the "" empty string. An integer cannot hold an empty string or any
other type of string. I don't know whether this will give errors or whether the
empty strings will be converted to zeroes, but either way they aren't doing what
you want.
You need to put an impossibly high number into PrevLowVal before you first call
CheckLowVal.
An alternative would be to define an extra variable as a Boolean. Call it
Initialised or similar. VBA will initialise it to false.
Then you can ask
If Not Initialised Then
and set up the big number in PrevLowVal, and also set Initialised to True.
I notice you have a large number of message box calls. Are you stepping the
code through with the debugger and using break points? Get to know the debugger
- it'll save you lots of time. Put a breakpoint on the first statement inside
your function.
I also note for the first time that you've defined this as a function, but it
doesn't ever return a value. What is it supposed to return? How do you call
it? How do you eventually use the lowest value?