|
本帖最后由 新东写西读 于 2018-8-12 12:57 编辑
Sub hz()
Dim r&, i&, k&
Dim arr, brr
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Sheets("确认单").Range("A5:L65536").ClearContents
With Worksheets("数据")
Sheets("数据").AutoFilterMode = False
r = .Cells(.Rows.Count, 1).End(xlUp).Row
arr = .Range("A3:AU" & r)
For i = 1 To UBound(arr)
If arr(i, 35) = Range("C2") Then
If Not d.Exists(arr(i, 32)) Then
n = n + 1
d(arr(i, 32)) = n
End If
End If
Next
ReDim brr(1 To UBound(arr), 1 To 12)
For i = 1 To UBound(arr)
If arr(i, 35) = Range("C2") Then
k = d(arr(i, 32))
brr(k, 1) = "=IF(RC[1]<>"""",ROW()-4,"""")"
brr(k, 2) = arr(i, 32)
brr(k, 11) = brr(k, 11) + arr(i, 47)
brr(k, 12) = arr(i, 31)
Select Case arr(i, 30)
Case "北京"
brr(k, 3) = brr(k, 3) + arr(i, 39)
brr(k, 4) = brr(k, 4) + arr(i, 47)
Case "上海"
brr(k, 5) = brr(k, 5) + arr(i, 39)
brr(k, 6) = brr(k, 6) + arr(i, 47)
Case "广州"
brr(k, 7) = brr(k, 7) + arr(i, 39)
brr(k, 8) = brr(k, 8) + arr(i, 47)
Case "深圳"
brr(k, 9) = brr(k, 9) + arr(i, 39)
brr(k, 10) = brr(k, 10) + arr(i, 47)
End Select
End If
Next
End With
Sheets("确认单").Range("A5").Resize(d.Count, 12) = brr
End Sub
如题!!!最好能有合并的格式,下图为增加模版样式,谢谢大神们!!
|
|