|
|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
代码如下。。。
Sub test1()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook, sht As Worksheet, sh As Worksheet
Set wb = ThisWorkbook
p = wb.Path & "\"
Set sht = wb.Sheets("考勤表")
' Set Rng = sht.Columns(1).Find("总计")
r = sht.Cells(Rows.Count, 1).End(3).Row
Set Rng = sht.[a1].Resize(r, 18)
arr = Rng.Value
ReDim brr(1 To UBound(arr) - 4, 0)
For i = 4 To UBound(arr) - 1 Step 2
Sum = 0
If arr(i, 3) <> Empty Then
For j = 5 To 16
If arr(i + 1, j) <> Empty Then
Sum = Sum + arr(i, j) * arr(i + 1, j)
Else
Sum = Sum + arr(i, 3) * arr(i, j)
End If
Next
Else
For j = 5 To 16
If arr(i + 1, j) <> Empty Then
Sum = Sum + arr(i, j) * arr(i + 1, j)
End If
Next
End If
brr(i - 3, 0) = Sum
Next
With sht
.[r4].Resize(UBound(brr)) = brr
.Cells(UBound(arr), UBound(arr, 2)) = "=sum(r4c:r[-1]c)"
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub
|
评分
-
1
查看全部评分
-
|