PDA

View Full Version : Using an IF statement with multiples



ukdane
05-02-2011, 02:57 AM
I need a formula which I can use with an if statement.

I'll try and explain.
I have a loop, where each loop X increases by one.
within the loop if x reaches a multiple of 20 (-1) then it should do something

So for the first series of loops (1-19) nothing happens
as soon as the loop hits 20 something should happen.
then the loops continue until it hits 39 ... the same thing that happened at 20 should occur, again at 58, 77, 96, and so on and so forth....

x=1

do until x = y+1

If x= 20, 39, 58,77,96 (etc etc) then 'this it the line that needs to be "forumlated"
dothis
else
donothing
end if

dosomething

x=x+1
loop


Thanks for your help.

GTO
05-02-2011, 03:32 AM
Try:
Sub exa()
Dim x As Long, y As Long

x = 1
y = 2000

Do Until x >= y + 1
Select Case True
Case x = 20
Debug.Print x
Case (x - 20) Mod 19 = 0 And x > 20
Debug.Print x
End Select
x = x + 1
Loop
End Sub