I assume you are either defining iGroupNum as integer or allowing it to be
defined automatically as integer.
Functions like Right, etc, work on strings, and might get in trouble with
integers.
Put an explicit definition in for iGroupNum as String (or perhaps call it
sGroupNum for correctness). Alternatively, use Mod and Int functions to act
directly on the integer values instead.
However, also ...
If Right(iGroupNum, 2) = "01" Or "02" Then
the "Or "02"" will always be true, probably. You need a complete test.
If Right(iGroupNum, 2) = "01" Or Right(iGroupNum, 2) = "02" Then
And, I don't know what you are expecting
If Right(iGroupNum, 2) <> "01" Or "02" Then
iGroupNum = iGroupNum
End If
to do. Even when you fix the If, the assignment statement doesn't do
anything. BTW for <>, you want to use "And", not "Or".