|
楼主 |
发表于 2016-3-15 15:48
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 840205910 于 2016-3-15 17:38 编辑
Private Sub CommandButton1_Click()
Set d = CreateObject("scripting.dictionary")
arr = Sheet4.UsedRange
r = Sheet2.[a65535].End(3).Row + 1
For i = 5 To UBound(arr)
If arr(i, 1) <> "" Then d(arr(i, 1) & "-" & arr(i, 2) & "-" & arr(i, 3) & "|" & arr(i, 4)) = ""
Next
k = d.Keys
For j = 0 To UBound(k)
ReDim brr(1 To UBound(arr), 1 To 5)
n = 0: jf = 0: df = 0: fd = 0
For i = 5 To UBound(arr)
If arr(i, 1) <> "" And arr(i, 1) & "-" & arr(i, 2) & "-" & arr(i, 3) & "|" & arr(i, 4) = k(j) Then
n = n + 1
jf = jf + arr(i, 8)
df = df + arr(i, 9)
fd = fd + arr(i, 10)
For p = 1 To 5
brr(n, p) = arr(i, p + 4)
Next
End If
Next
Y = Application.RoundUp(n / 7, 0)
For q = 1 To Y
ReDim crr(1 To 7, 1 To 5)
Sheet3.Range("a1", "e12").Copy Sheet2.Range("a" & r)
For w = 1 To 7
For g = 1 To 5
If n >= (q - 1)*7 + w Then crr(w, g) = brr((q - 1) * 7 + w, g)
Next
Next
Sheet2.Range("a" & r + 3).Resize(7, 5) = crr
Sheet2.Range("d" & r + 10) = jf
Sheet2.Range("e" & r + 10) = df
Sheet2.Range("b" & r + 10) = "合计:" & DX(df)
Sheet2.Range("a" & r + 10) = Sheet2.Range("a" & r + 10) & fd
Sheet2.Range("c" & r + 1) = "日期:" & Split(Split(k(j), "|")(0), "-")(0) & "年" & Split(Split(k(j), "|")(0), "-")(1) & "月" & Split(Split(k(j), "|")(0), "-")(2) & "日"
Sheet2.Range("e" & r + 1) = "第" & Split(k(j), "|")(1) & "号" & Chr(10) & Format(q, "000") & "/" & Format(Y, "000")
Erase crr
r = r + 12
Next
Erase brr
Next
End Sub
|
|