Sub macro()
Dim i As Integer
Dim score As Integer
Dim total As Long
Dim average As Double
Dim count80 As Integer
Dim maxScore As Integer
Dim maxRow As Integer
Dim evenTotal As Long
total = 0
count80 = 0
evenTotal = 0
maxScore = Range("A1").Value
maxRow = 1
For i = 1 To 20
score = Range("A" & i).Value
total = total + score
If score >= 80 Then
count80 = count80 + 1
End If
If score Mod 2 = 0 Then
evenTotal = evenTotal + score
End If
If maxScore < score Then
maxScore = score
maxRow = i
End If
Next i
average = total / 20
Range("B22").Value = total
Range("B23").Value = average
Range("B24").Value = count80
Range("B25").Value = maxScore
Range("B26").Value = maxRow
Range("B27").Value = evenTotal
End Sub

コメント