|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 计算()
Application.ScreenUpdating = False
Dim ar As Variant, cr As Variant
Dim i As Long, r As Long, rs As Long
With Sheets("sheet1")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("ai1:ak" & rs + 1) = Empty
ar = .Range("a1:ak" & rs)
For i = 2 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
hj = 0: gs = 0: lh = ""
For j = 33 To 5 Step -2
If Trim(ar(i, j)) <> "" Then
If IsNumeric(ar(i, j)) Then
lh = j
Exit For
End If
End If
Next j
For j = 5 To lh - 2 Step 2
If Trim(ar(i, j)) <> "" Then
If IsNumeric(ar(i, j)) Then
hj = hj + ar(i, j)
gs = gs + 1
lh = j
End If
End If
Next j
zf = hj * 0.5 + ar(i, lh) * 0.5
pjf = zf / (gs + 1)
ar(i, 35) = zf
ar(i, 36) = gs + 1
ar(i, 37) = pjf
End If
Next i
.Range("a1:ak" & rs) = ar
End With
MsgBox "ok!"
End Sub
|
|