1. 程式人生 > >計算工資大於2500的平均值

計算工資大於2500的平均值

span spa -s msgbox class amp 大於等於 判斷大小 next

大神:

1 Sub 大於等於2500的平增工資()
2 Dim rs%, rng%, lj&, k%
3 For rs = 1 To 60
4     Range("b2:c20")(rs).Select
5      rng = Range("b2:c20")(rs)
6     If rng >= 2500 Then lj = lj + rng: k = k + 1
7 Next rs
8     MsgBox "大於等於2500的平均分為:" & Int(lj / k)
9 End Sub

我的:

 1 Sub 判斷大小並取平均值()
 2 Dim i%, m%, n!, rg As Range, k
3 For Each rg In Range("a1", "f11") 4 m = rg.Value 5 rg.Select 6 If m >= 2500 Then n = n + m: i = i + 1 7 Next 8 k = n / i 9 MsgBox "大於2500的平均工資是:" & k 10 End Sub

計算工資大於2500的平均值