- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e:
¿é¤J¦~¤À:
°õ¦æµ²ªG:
Option Explicit
Sub TEST()
Application.ScreenUpdating = False
Dim Brr, Crr(1 To 1000, 1 To 3), Z, A, i&, R&, j%, N%, Y$, T$, xR As Range
ActiveSheet.UsedRange.Offset(, 6).EntireColumn.Delete
Y = InputBox("½Ð½T»{¬O§_¥¿½T!", "½Ð¿é¤J·J¾ã¦~¤À", Format(CDate(Format(Date, "YYYY/MM/") & 1) - 1, "YYYY"))
If StrPtr(Y) = 0 Then Exit Sub
If Not Y Like "####" Then MsgBox "½Ð¿é¤J¥¿½T®æ¦¡¦~¥÷": Exit Sub
Set Z = CreateObject("Scripting.Dictionary"): Set xR = [G1]
Brr = [A1].CurrentRegion
For i = 2 To UBound(Brr)
If Not IsDate(Brr(i, 1)) Then GoTo i01
If Format(Brr(i, 1), "YYYY") <> Y Then GoTo i01 Else T = Brr(i, 2)
A = Z(T): R = Z(T & "/r")
If Not IsArray(A) Then A = Crr: N = N + 1
R = R + 1: A(R, 1) = Brr(i, 1): A(R, 2) = Brr(i, 3): A(R, 3) = Brr(i, 5)
Z(T) = A: Z(T & "/r") = R
i01: Next
If N = 0 Then Exit Sub
For i = 0 To Z.Count - 1
T = Z.KEYS()(i): If Not IsArray(Z(T)) Then GoTo i02
With xR.Resize(2, 3)
.Borders.LineStyle = xlContinuous
.Cells(1) = T: .Cells(2) = "¤ä¥X©ú²Óªí": .Cells(4) = "¤é´Á": .Cells(5) = "ºKn": .Cells(6) = "¤ä¥X"
For j = 7 To 10: .Borders(j).Weight = 4: Next
End With
xR.Interior.ColorIndex = 33: xR(2).Resize(, 3).Interior.ColorIndex = 1: xR(2).Resize(, 3).Font.ColorIndex = 2
With xR(3).Resize(Z(T & "/r"), 3)
.Value = Z(T)
.Item(.Count + 2) = "¦Xp"
.Item(.Count + 3) = "=SUM(" & .Columns(3).Address & ")"
.Borders.LineStyle = xlContinuous
.ShrinkToFit = True
For j = 7 To 10: .Borders(j).Weight = 4: Next
End With
Set xR = xR(, 5)
i02: Next
End Sub |
|