The most flexible way is to use a While loop instead of For-Next.
If you know the step size is positive then the equivalent loops look like this:
If xStep is negative then you would use "While x >= xLast".
If you don't know the sign of xStep in advance then you must write code to handle both cases.
This complication is the reason For-Next insists on a constant step value.
If you know the step size is positive then the equivalent loops look like this:
; Set values for xFirst and xLast here. xStep must be constant. For x = xFirst To xLast Step xStep ; do something Next ; Set values for xFirst, xLast and xStep here. x = xFirst While x <= xLast ; do something x = x + xStep Wend
If xStep is negative then you would use "While x >= xLast".
If you don't know the sign of xStep in advance then you must write code to handle both cases.
This complication is the reason For-Next insists on a constant step value.