Sub test()
standard = Array(1, 2, 3, 4, 5)
Dim result As Long, Count As Long, Sum As Long
For r = 0 To 4
'For x = 2 To 18
Count = 0
Sum = 0
For y = 2 To 18
If ThisWorkbook.Sheets(1).Cells(y, 1).Value = standard(r) Then
If ThisWorkbook.Sheets(1).Cells(y, 2).Value <> "" Then
Count = Count + 1
Sum = Sum + ThisWorkbook.Sheets(1).Cells(y, 2).Value
Else
End If
Else
End If
Next y
'Next x
'result = Sum / Count
If Sum = 0 Or Count = 0 Then
Debug.Print "条件不充分"
Else
Debug.Print Sum
Debug.Print Count
End If
'ThisWorkbook.Sheets(1).Cells(5 + r, 2 + r).Value = Sum / Count
Next r
End Sub