|
Logical check based on Floor 27, assumed only one ball is different from others
Sub BallCheck()
Const H = " is heavier than others "
Const S = " is smaller than others " ' -----> I forgot to change it to lighter
Const Ball = "Ball "
Dim Answer As String
Set wFx = Application.WorksheetFunction
' Check 1
'
If wFx.Sum([B1:B4]) = wFx.Sum([B5:B8]) Then ' Check 1 Option 1
' Check 2 ( Option 1A )
If wFx.Sum([B1:B3]) = wFx.Sum([B9:B11]) Then
' Check 3 ( Option 1A )
If [B1] < [B12] Then
Answer = Ball & "12" & H
ElseIf [B1] > [B12] Then
Answer = Ball & "12" & S
End If
Else
' Check 2 ( Option 1B )
If wFx.Sum([B1:B3]) < wFx.Sum([B9:B11]) Then
' Check 3 ( Option 1B )
If [B9] = [B10] Then
Answer = Ball & "11" & H
Else
Answer = IIf([B9] < [B10], Ball & "10" & H, Ball & "9" & H)
End If
Else ' Check 2 ( Option 1C )
' Check 3 ( Option 1C )
If [B9] = [B10] Then
Answer = Ball & "11" & S
Else
Answer = IIf([B9] < [B10], Ball & "9" & S, Ball & "10" & S)
End If
End If
End If
'
' Option 1 End
'
Else
If wFx.Sum([B1:B4]) < wFx.Sum([B5:B8]) Then ' Check 1 Option 2
' Check 2 ( Option 2A )
If wFx.Sum([B2], [B3], [B5]) = wFx.Sum([B4], [B8], [B9]) Then
' Check 3 ( Option 2A )
If [B6] = [B7] Then
Answer = Ball & "1" & S
Else
Answer = IIf([B6] < [B7], Ball & "7" & H, Ball & "6" & H)
End If
Else
' Check 2 ( Option 2B )
If wFx.Sum([B2], [B3], [B5]) > wFx.Sum([B4], [B8], [B9]) Then
If [B4] = [B9] Then
Answer = Ball & "5" & H
ElseIf [B4] < [B9] Then
Answer = Ball & "4" & S
End If
Else
' Check 2 ( Option 2C )
If [B2] = [B3] Then
Answer = Ball & "8" & H
Else
Answer = IIf([B2] < [B3], Ball & "2" & S, Ball & "3" & S)
End If
End If
End If
'
' Option 2 End
'
Else ' Check 1 Option 3
' Check 2 ( Option 3A )
If wFx.Sum([B2], [B3], [B5]) = wFx.Sum([B4], [B8], [B9]) Then
' Check 3 ( Option 3A )
If [B6] = [B7] Then
Answer = Ball & "1" & H
Else
Answer = IIf([B6] < [B7], Ball & "6" & S, Ball & "7" & S)
End If
Else
' Check 2 ( Option 3B )
If wFx.Sum([B2], [B3], [B5]) < wFx.Sum([B4], [B8], [B9]) Then
If [B4] = [B9] Then
Answer = Ball & "5" & S
ElseIf [B4] > [B9] Then
Answer = Ball & "4" & H
End If
Else
' Check 2 ( Option 3C )
If [B2] = [B3] Then
Answer = Ball & "8" & S
Else
Answer = IIf([B2] < [B3], Ball & "3" & H, Ball & "2" & H)
End If
End If
End If
End If
'
' Option 3 End
'
End If
If Answer <> "" Then MsgBox Answer
End Sub
URMmiBSE.zip
(12.66 KB, 下载次数: 52)
[此贴子已经被作者于2003-8-4 17:17:57编辑过] |
|