I won't bring the entire code, I'll try to show what is relevant. The following code (which is inside a loop, but it doesn't matter) calls a function (compareStrings) which returns an integer.
Sheet1.Range("S" & i).Value = compareStrings(sheet1.Range("J" & i).Value, sheet1.Range("K" & i).Value)
So basically I have a loop that fills column S with integers. I then sort S column in ascending order. later I have another loop, that is supposed to do something with all the values that are less than 5.
The loop looks like this:
With Sheet1.Range("S" & i)
Do Until .Value < 5
If .Value = 0 Then
'some statement
Else
'some statement
End If
i = i + 1
Loop
End With
For some reason it doesn't go in the loop although I have many rows with values that are < 5. I actually tried to change it to <> and it doesn't go in either. It is as if it doesn't see it as an integer, although I have put integers in these cells.
Any ideas?
Thanks
Debug.Print .Valuestatement and watching the immediate window.<inDo Until .Value < 5- i.e. if the value is less than 5, stop and don't do anything? Your logic doesn't seem to make sense, especially if the values are in ascending order.