- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¦^´_ 1# shuo1125
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æµ²ªG:
Option Explicit
Sub TEST_1() '¡ô
Dim Brr, Crr(1 To 100, 1 To 100), Z, A, B$, i&, R&, C%, Y&, X%, T$, K%, S%, N&, M, Q
Set Z = CreateObject("Scripting.Dictionary"): C = 1: R = 1
A = Array(0, 5000, 10000, 50000, 100000, 500000, 10 ^ 6, 5000000, 10 ^ 7, 10 ^ 10)
K = UBound(A): S = K + 3
For i = 0 To K - 1
R = R + 1
Crr(R, 1) = A(i) + 1 & "~" & vbLf & A(i + 1): Crr(R + S, 1) = Crr(R, 1)
Z(A(i + 1) & "$") = R: Z(A(i + 1) & "N") = R + S
Next
Brr = Range([¸ê®Æ!D2], [¸ê®Æ!A65536].End(3))
Sheets("²Îp").UsedRange.Clear
With Sheets("²Îp").[A1:D4].Resize(UBound(Brr))
.Value = Brr
.Sort KEY1:=.Item(1), Order1:=1, Header:=2, Orientation:=1: Brr = .Value
For i = 1 To UBound(Brr)
T = Brr(i, 1)
If Z(T & "y") = "" Then
C = C + 1: Crr(1, C) = T: Z(T & "y") = C: Crr(S + 1, C) = T
End If
Next
.Sort KEY1:=.Item(4), Order1:=1, Header:=2, Orientation:=1
Brr = .Value: .Clear
End With
Crr(1, 1) = "·JÁ`-NTD": Crr(S + 1, 1) = "·JÁ`-QTY": B = "[Total]"
R = R + 1: Crr(R, 1) = B: Crr(R + S, 1) = B
C = C + 1: Crr(1, C) = B: Crr(S + 1, C) = B
'=========================================
For i = 1 To UBound(Brr)
Q = Val(Brr(i, 4))
If Q > M Then N = N + 1: M = A(N)
X = Z(Brr(i, 1) & "y"): Y = Z(M & "$")
Crr(Y, X) = Crr(Y, X) + Q: Crr(R, X) = Crr(R, X) + Q
Crr(Y, C) = Crr(Y, C) + Q: Crr(R, C) = Crr(R, C) + Q
Crr(Y + S, X) = Crr(Y + S, X) + 1: Crr(R + S, X) = Crr(R + S, X) + 1
Crr(Y + S, C) = Crr(Y + S, C) + 1: Crr(R + S, C) = Crr(R + S, C) + 1
Next
With [²Îp!A1].Resize(R + S, C)
.Columns.ColumnWidth = 14
Intersect(.Cells, Rows("1:" & K + 2)).Borders.LineStyle = 1
Intersect(.Cells, Rows(S + 1 & ":" & R + S)).Borders.LineStyle = 1
Union(.Rows(1), .Rows(K + 2), .Rows(S + 1)).Font.Bold = True
Union(.Rows(R + S), .Columns(C)).Font.Bold = True
Range([B2], .Cells(K + 2, C)).NumberFormatLocal = "#,##0_ "
Range(.Cells(S + 2, 2), .Cells(R + S, C)).NumberFormatLocal = "#,##0_ "
.Value = Crr
End With
Set Z = Nothing: Erase Brr, Crr, A
End Sub |
|