vba练习-while循环

vba练习-while循环
统计所有学生的平均成绩,当A列继续输入时,仍能统计。
Sub 统计()
Dim i, total, count
total = 0
count = 0
i = 2
Do While Cells(i, 1) <> ""
total = total + Cells(i, 2)
count = count + 1
i = i + 1
Loop
If count > 0 Then
Cells(3, 3).Value = total / count
End If
End Sub

猜你喜欢

转载自blog.51cto.com/11729955/2325322