|
楼主 |
发表于 2023-6-28 12:45
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
谢谢,基本猜对,轻微修改,测试对比,没速度上的提升,见代码,估计是计算语句的下一半耗时了。可否也用数组法修改下?因为我想,下一半代码是汇总内容的,若先保存在数组中,最后一次性写入,应该能提速。表2区域,A2:AG7。表1区域A2:AH,(第2行开始往下写)- arr = Sheet4.[A1].CurrentRegion
- ReDim brr(1 To UBound(arr), 1 To 1)
-
- For c = 1 To UBound(arr, 2) - 2
- For i = 1 To UBound(arr)
- brr(i, 1) = arr(i, c)
- Next
- Sheet3.Range("C1").Resize(UBound(brr)) = brr
-
- For d = c + 1 To UBound(arr, 2) - 1
- For i = 1 To UBound(arr)
- brr(i, 1) = arr(i, d)
- Next
- Sheet3.Range("D1").Resize(UBound(brr)) = brr
-
- For e = d + 1 To UBound(arr, 2)
- For i = 1 To UBound(arr)
- brr(i, 1) = arr(i, e)
- Next
- Sheet3.Range("E1").Resize(UBound(brr)) = brr
-
- Calculate
-
- If Application.WorksheetFunction.CountBlank(Sheet2.Range("B2:B7")) < 6 Then
- For k = 2 To 7
- If Application.WorksheetFunction.CountBlank(Sheet2.Cells(k, "B")) < 1 Then
- n = n + 1
- Sheet1.Cells(n, 1).Value = Sheet3.Range("C1").Value & "-" & Sheet3.Range("D1").Value & "-" & Sheet3.Range("E1").Value
- Sheet1.Range(Sheet1.Cells(n, "B"), Sheet1.Cells(n, "AH")).Value = Sheet2.Range(Sheet2.Cells(k, "A"), Sheet2.Cells(k, "AG")).Value
- End If
- Next k
- End If
- Next e, d, c
复制代码
|
|