PDA

View Full Version : Solved: Case Select



Saladsamurai
09-02-2009, 12:23 PM
In the following code, the Counter and the Sum of the "Cases" should clearly be equal.

The sum however is =443 while the Counter = 431. (The Counter, I believe, is correct. I did a COUNTIF to check).

Is there something blatently wrong with my code? Thanks!

For i = 1 To nRow
For j = 1 To nCol
If T_CFD.Cells(i, j) <> "" And T_CFD.Cells(i, j) <> "$" Then

MyError_T = T_CFD.Cells(i, j) - T_ISX.Cells(i, j)

If Abs(MyError_T) > MyMax_T Then
MyMax_T = Abs(MyError_T)
End If

MyError_T = abs(MyError_T)

Select Case MyError_T

Case Is <= 5
Within5 = Within5 + 1

Case Is < 10
Within5_10 = Within5_10 + 1

Case Is >= 10
Over10 = Over10 + 5

End Select

Counter = Counter + 1

End If

Next j
Next i

MsgBox Within5 + Within5_10 + Over10 & " " & Counter

EDIT: "MyError_T = Abs(MyError_T)"

mdmackillop
09-02-2009, 12:30 PM
Hmmm!

Over10 = Over10 + 5

Saladsamurai
09-02-2009, 12:32 PM
:banghead: :rofl: :whistle:

Hmmmm! is Right!

That's classic...

Thanks!!