|
楼主 |
发表于 2022-4-26 03:27
|
显示全部楼层
- Sub aaa1() '自定义函数将不同清单放在末尾,不能实现放在对应楼栋下面
- Dim cc, brr, crr
- t = Timer
- Sheets("实现功能2").Range("c5").Resize(10000, 20).ClearContents
- r1 = Sheets("截止上月源数据").Range("c" & Rows.Count).End(xlUp).Row
- r2 = Sheets("本月源数据").Range("c" & Rows.Count).End(xlUp).Row
- brr = Sheets("截止上月源数据").Range("c2:i" & r1)
- crr = Sheets("本月源数据").Range("c2:i" & r2)
- drr = Arraymerge("5,,,,1;2;3;4,", brr, crr)
- r3 = Sheets("实现功能2").Range("c" & Rows.Count).End(xlUp).Row + 1
- Sheets("实现功能2").Range("c" & r3 + 1).Resize(UBound(drr), UBound(drr, 2)) = drr
- MsgBox Timer - t
- End Sub
复制代码
仅能实现部分还请各位老师不吝赐教
基于BOM结构的分级数据对比匹配及累加求和-初稿.rar
(194.81 KB, 下载次数: 4)
修改调整代码后,不知道什么问题,老是出现错误
调整后的代码如下
- Sub aaa2() '代码不知哪里问题
- Dim cc, brr(), crr()
- t = Timer
- Sheets("实现功能2").Range("c5").Resize(10000, 20).ClearContents
- r1 = Sheets("截止上月源数据").Range("c" & Rows.Count).End(xlUp).Row
- r2 = Sheets("本月源数据").Range("c" & Rows.Count).End(xlUp).Row
- arr = Sheets("截止上月源数据").Range("c2:i" & r1)
- crr2 = Sheets("本月源数据").Range("c2:i" & r2)
- m = 0
- ReDim arr2(1 To 19)
- For i = 1 To r1
- On Error Resume Next
- If Right(arr(i, 1), 1) = "栋" And arr(i, 1) <> "" Then
- m = m + 1
-
- arr2(m) = Left(arr(i, 1), 4)
- End If
- Next i
- For j = 1 To UBound(arr2)
- n = 0: n2 = 0
- For i = 1 To r1
- If Left(arr(i, 1), 4) = arr2(j) Then
- n = n + 1
- ReDim Preserve brr(n, 7)
- For ii = 0 To UBound(arr, 2)
- brr(n, ii) = arr(i, ii)
- Next
- End If
- Next
-
- For g = 1 To r2
- If Left(crr2(g, 1), 4) = arr2(j) Then
- n2 = n2 + 1
- ReDim Preserve crr(n2, 7)
- For gg = 0 To UBound(crr2, 2)
- crr(n2, gg) = crr2(g, gg)
- Next
- End If
- Next
- drr = Arraymerge("5,,,,1;2;3;4,", brr, crr)
-
- r3 = Sheets("实现功能2").Range("c" & Rows.Count).End(xlUp).Row + 1
- Sheets("实现功能2").Range("c" & r3 + 1).Resize(UBound(drr), UBound(drr, 2)) = drr
- Erase drr
- Next
-
- MsgBox Timer - t
- End Sub
复制代码
|
|