Two questions:

1. In your code above, you have the following.
Code:
IF W0 < 13105 Then loop1
IF W0 < 26210 Then loop2
IF W0 < 39315 Then loop3
IF W0 < 52420 Then loop4
IF W0 <= 65525 Then loop5
Lets take W0=10000 then all of these IF statements will be true and be executed. Or say W0=28000; in this case last three IF statements will be executed, etc...

You should change it as follows.
Code:
IF W0 < 13105 Then 
	loop1
ELSE
	IF W0 < 26210 Then 
		loop2
	ELSE
		IF W0 < 39315 Then 
			loop3
		ELSE
			IF W0 < 52420 Then 
				loop4
			ELSE
				IF W0 <= 65525 Then loop5
			ENDIF
		ENDIF
	ENDIF
ENDIF

OR use a select case, it would make it easier to follow the logic.

2. Forget this one.


---------------------------