|
给你一段代码,自己改
Sub 横向汇总录入表() '使用数组从上到下汇总
Dim ws As Worksheet
Dim fla As Boolean
Dim arr, brr()
Set ws = Worksheets("数据录入")
fla = False
hj = 0
' t = Timer
With ws
r = .Cells(.Rows.Count, 1).End(xlUp).Row
c = .Cells(1, .Columns.Count).End(xlToLeft).Column
arr = .Range(.Cells(3, 1), .Cells(r, c))
End With
ReDim brr(1 To UBound(arr, 2))
hs = UBound(arr)
For i = hs - 1 To 1 Step -1
BM = CStr(arr(i, 1))
j = i + 1
Do While CStr(arr(j, 1)) Like BM & "*"
If CStr(arr(j, 1)) Like BM & "??" Then
For k = 5 To c
'For k = 3 To c
brr(k) = brr(k) + arr(j, k)
Next
fla = True
End If
j = j + 1
If j > hs Then Exit Do
Loop
If fla Then
'For k = 3 To c
For k = 5 To c
arr(i, k) = brr(k)
Next
ReDim brr(1 To UBound(arr, 2))
fla = False
End If
Next
Worksheets("数据录入").Range("a3").Resize(UBound(arr), UBound(arr, 2)) = arr
' MsgBox Timer - t
End Sub
|
评分
-
1
查看全部评分
-
|