Glory
Well-known Member
- Joined
- Mar 16, 2011
- Messages
- 640
From VBA Help:
From my module:
"Iterations" is successfully filling with the desired value, but all the case statements are being skipped even though there are matches.
Incidentally, if I do this instead:
The code works fine, but I thought the whole point of 'Select Case' was to evaluate the testexpression once instead of multiple times.
Code:
Select Case Number ' Evaluate Number.
Case 1 To 5 ' Number between 1 and 5, inclusive.
Debug.Print
End Select
From my module:
Code:
Select Case Iterations
Case 1 Or 6
SetProps = 6
Case 2 Or 7
SetProps = 24
Case 3 Or 8
SetProps = 42
Case 4 Or 9
SetProps = 60
Case 5 Or 10
SetProps = 78
End Select
"Iterations" is successfully filling with the desired value, but all the case statements are being skipped even though there are matches.
Incidentally, if I do this instead:
Code:
Select Case True
Case Iterations = 1 Or Iterations = 6
SetProps = 6
Case Iterations = 2 Or Iterations = 7
SetProps = 24
Case Iterations = 3 Or Iterations = 8
SetProps = 42
Case Iterations = 4 Or Iterations = 9
SetProps = 60
Case Iterations = 5 Or Iterations = 10
SetProps = 78
End Select
The code works fine, but I thought the whole point of 'Select Case' was to evaluate the testexpression once instead of multiple times.