|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub qs()
- Dim arr, i, dic
- Set dic = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- a = [{1,3,4,5,6,7,8,9,10}]
- With Sheet1
- arr = .Range("a4:j" & .Cells(Rows.Count, 1).End(3).Row)
- ReDim brr(1 To UBound(arr), 1 To 9)
- For i = 1 To UBound(arr)
- dic(arr(i, 2)) = i
- Next
- End With
- cl = 2
- With Sheet2
- .Range("b2:ad2,b4:ad1000") = "": .Range("b4:ad1000").Borders.LineStyle = xlNone
- For Each k In dic.keys
- dy = dy + 1
- d2.RemoveAll: m = 0: sm = 0
- If cl > 23 Then cl = 2: .Range("b2:ad2,b4:ad1000") = "": .Range("b4:ad1000").Borders.LineStyle = xlNone
-
- For i = 1 To UBound(arr)
- If arr(i, 2) = k Then
- m = m + 1
- d2(arr(i, 1)) = ""
- For j = 1 To 9
- brr(m, j) = arr(i, a(j))
- Next
- sm = sm + arr(i, 10)
- End If
- Next
- If m <= 43 Then
- .Cells(2, cl).Value = d2.Count & "天": .Cells(2, cl + 1).Value = k
- .Cells(2, cl + 8) = sm
- .Cells(4, cl).Resize(m, 9) = brr
- .Cells(4, cl).Resize(m, 9).Borders.LineStyle = xlContinuous
- Else
-
- .Cells(2, cl).Value = d2.Count & "天": .Cells(2, cl + 1).Value = k
- .Cells(2, cl + 8) = sm
- .Cells(4, cl).Resize(43, 9) = brr
- .Cells(4, cl).Resize(43, 9).Borders.LineStyle = xlContinuous
-
- cl = cl + 10
- If cl > 23 Then cl = 2: .Range("b2:ad2,b4:ad1000") = "": .Range("b4:ad1000").Borders.LineStyle = xlNone
- rww = 3
- For rr = 44 To m
- rww = rww + 1
- .Cells(rww, cl).Resize(1, 9) = Application.Index(brr, m, 0)
- Next
- .Cells(4, cl).Resize(m - 43, 9).Borders.LineStyle = xlContinuous
- End If
- If dy Mod 3 = 0 Then
-
- ' .Range("a1:ad47").PrintOut
- ElseIf dy = dic.Count Then
- ' .Range("a1:ad47").PrintOut
- End If
- cl = cl + 10
- Next
- End With
- Set dic = Nothing
- End Sub
复制代码 |
|