How do I find even and odd numbers in this list?
Sub kati()
For li = 1 To 10
For col = 1 To 10
How do I find even and odd numbers in this list?
Sub kati()
For li = 1 To 10
For col = 1 To 10
Use the Mod operator . If the remainder of the division by 2 is 0, then the number is even. Example:
If li Mod 2 = 0 then 'faça o que quiser aqui
If col Mod 2 = 0 then 'faça o que quiser aqui
Same as the Mod operator, it can be done this way (considering it is an array):
If Matriz(li, col) / 2 - Int(Matriz(li, col) / 2) = 0 Then MsgBox Matriz(li, col) & " é Par" Else MsgBox Matriz(li, col) & " é Impar"