Consulting

Results 1 to 3 of 3

Thread: Solved: Case Select

  1. #1

    Solved: Case Select

    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!

    [vba]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[/vba]

    EDIT: "MyError_T = Abs(MyError_T)"

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hmmm!
    [VBA]
    Over10 = Over10 + 5

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3


    Hmmmm! is Right!

    That's classic...

    Thanks!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •