请测试》》》
- Sub aa()
- Application.ScreenUpdating = False
- Dim arr, brr, crr(), r&, i&, j%
- Set d = CreateObject("scripting.dictionary")
- With Sheets("原表1")
- r = .Cells.Find("*", Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row '计算工作表最后一个非空行号
- arr = .Range("a2:o" & r)
- For i = 1 To UBound(arr)
- d(arr(i, 1)) = i
- Next
- End With
- With Sheets("增减表")
- r = .Cells.Find("*", Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row '计算工作表最后一个非空行号
- brr = .Range("a2:g" & r)
- For i = 1 To UBound(brr)
- arr(d(brr(i, 1)), 6) = brr(i, 6): arr(d(brr(i, 1)), 7) = brr(i, 7)
- Next
- End With
- ReDim crr(1 To UBound(arr) + 1, 1 To 3)
- crr(1, 1) = "行政编号": crr(1, 2) = "教师名称": crr(1, 3) = "实际课时"
- For i = 1 To UBound(arr)
- arr(i, 5) = arr(i, 10) + arr(i, 6)
- crr(i + 1, 1) = arr(i, 1): crr(i + 1, 2) = arr(i, 2): crr(i + 1, 3) = arr(i, 5)
- Next
- With Sheets("结果导出")
- Sheet3.UsedRange.ClearContents
- .[a1].Resize(UBound(crr), 3) = crr
- End With
- With Sheets("原表1")
- r = .Cells.Find("*", Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row '计算工作表最后一个非空行号
- .Range("a2:o" & r) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |