Dim a As Integer, b As Integer, c As Integer, s As Integer, rowpos As Integer, sum As Integer, z As Integer, n As String Dim name As String, d As String, title As String
title = "バド部の人数" rowpos = 3 sum = 0 Do name = Cells(rowpos, 2) a = Cells(rowpos, 4).Value b = Cells(rowpos, 7).Value c = Cells(rowpos, 10).Value s = a + b If name = "" Then rowpos = rowpos + 1 name = Cells(rowpos, 2) a = Cells(rowpos, 4).Value b = Cells(rowpos, 7).Value c = Cells(rowpos, 10).Value s = a + b
If s < c Then d = name Debug.Print d z = 1 sum = sum + z
End If rowpos = rowpos + 1 Loop While name <> ""
If sum = 0 Then Debug.Print "該当校なし" Else n = CStr(sum) Debug.Print "合計" + n + "校" End If End Sub