Bug in Sheets: If statement with "<" operator

Bug in Sheets: If statement with "<" operator

Hello, last weekend I was fighting against a very ugly bug. It happens in a procedure like this

  1. private sub ChangeColor()
  2.   dim x as variant
  3.   dim iLimit as integer
  4.   
  5.   iLimit = range("Player").value
  6.   for each x in range("User")
  7.     x.Select
  8. (1)    if iLimit > x.value and not isempty(x) then
  9. (2)    if x.value < iLimit and not isempty(x) then
  10.       Selection.Interior.Color = 49407
  11.     else
  12.       Selection.Interior.Color = RGB(255,255,255)
  13.     end if
  14.   next x
  15. end sub
When I use (1) it works correctly, if I use (2) I get following error message when I press run:
  1. Encountered "1" at line 73, column 31.Was expecting one of:
  2. <NL>,  ":",  "&",  <DOT>,  "^",  "(",  "-",  "+",  "=",  ">",  "<",  ">=",  "<=",  "<>",  "\\",  "/",  "*",  "IS",  "LIKE",  "MOD",  "AND",  "OR",  "XOR",  "EQV",  "IMP",  
The strange thing is, and this makes this bug so ugly, line 73 is in a total different area of the code about 40 lines below. This code is in line 73:
  1.     iActualRow = iActualRow + 1
For whatever reason the compiler doesn't recognize the "+" between "iActualRow" and "1". Changing the above code back to (1) solves all issues.