- ©«¤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
|
¦^´_ 30# shuo1125
ÁÂÁ«e½ú¤@°_¾Ç²ß
Option Explicit
Sub TEST()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim Brr, A, y, Z, Yk, T2$, T3$, T8$, T11$, T12$, T20$, S1$, S2$
Dim x%, C%, N&, i&, P&, Crr(1 To 1000, 1 To 20)
Set y = CreateObject("Scripting.Dictionary")
Z = Array(, 4, 8, 10, 12, 14, 16, 15, 17)
On Error Resume Next
Sheets("ÅçÃÒªí").Delete
On Error GoTo 0
Sheets("¸ê®Æ°Ï").Copy Before:=Sheets(1)
With Sheets(1): .Name = "ÅçÃÒªí": End With
Brr = Range([ÅçÃÒªí!U1], [ÅçÃÒªí!A65536].End(3))
For i = 2 To UBound(Brr)
T2 = Brr(i, 2): T3 = Brr(i, 3)
S1 = T2 & "|" & T3: y(S1 & "/b") = T2: y(S1 & "/c") = T3
A = y(S1): y(S1 & "/¾lÃB") = Brr(i, 18)
If Not IsArray(A) Then A = Crr
T8 = Brr(i, 8): T11 = Brr(i, 11)
T12 = Brr(i, 12): T20 = Brr(i, 20)
If InStr("/¨R±b/¥ß±b/", "/" & T20 & "/") = 0 Then
Application.Goto Sheets("ÅçÃÒªí").Rows(i)
MsgBox "TÄ椣©ú ¥ß¨R±bÃþ§O": Exit Sub
End If
If T20 = "¨R±b" Then
If T11 Like "#####*" = False Then
Application.Goto Sheets("ÅçÃÒªí").Rows(i)
MsgBox "¨R±b³ÆµùÄ沧±`": Exit Sub
End If
If y.Exists(T11 & "|" & T12) = Empty Then
Application.Goto Sheets("ÅçÃÒªí").Rows(i)
MsgBox "µLªk¨R±b": Exit Sub
End If
End If
If T20 = "¥ß±b" Then
N = y(S1 & "|r"): N = N + 1: y(S1 & "|r") = N
S2 = T8 & "|" & T12: y(S2) = N
For x = 1 To 4: A(N, x) = Brr(i, Z(x)): Next
For x = 5 To 6
A(N, x) = Brr(i, Z(x)) + Brr(i, Z(x + 2))
A(N, x + 14) = A(N, x)
Next
y(S1) = A: GoTo i01
End If
C = Format(Brr(i, 4), "M") + 6
S2 = T11 & "|" & T12
A(y(S2), C) = Brr(i, 16) + Brr(i, 17)
A(y(S2), 20) = A(y(S2), 20) - A(y(S2), C)
P = Brr(i, 14) + Brr(i, 15)
A(y(S2), 19) = A(y(S2), 19) - P
y(S1) = A
i01:
Next
'====================================
For Each Yk In y.keys
If IsArray(y(Yk)) Then
On Error Resume Next
Sheets(Val(Yk) & "").Delete
On Error GoTo 0
Sheets("¬ì¥Ø¾lÃBªí").Copy Before:=Sheets(1)
With Sheets(1)
.Name = Val(Yk)
.UsedRange.Offset(5, 0).Delete
With .[A5].Resize(y(Yk & "|r"), 20)
.Value = y(Yk)
Intersect([E:T], .Cells).NumberFormatLocal = _
"_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-"
End With
.[C3] = y(Yk & "/c")
.[C3] = .[C3] & "¡m" & y(Yk & "/b") & "¡n"
N = .Cells(Rows.Count, "F").End(3).Row
With .Cells(N + 1, "F").Resize(1, 15)
.Value = "=SUM(F5:F" & N & ")"
If .Item(14) <> .Item(15) Then .Item(14) = "NA"
If y(Yk & "/¾lÃB") <> .Item(15) Then
.Item(15)(2) = "¡ôÄY«¿ù»~!¾lÃB¦Xp" & _
"¤£µ¥©ó¸ê®Æ°Ï¾lÃB: " & vbLf & y(Yk & "/¾lÃB")
.Interior.ColorIndex = 3
MsgBox "ÄY«¿ù»~"
Exit Sub
End If
End With
End With
End If
Next
Set y = Nothing: Erase Brr, Crr, Z, A
End Sub
Sub ²M°£¤£²Å±ø¥óªº¦C_¨Ã±Æ§Ç()
Dim Arr, Brr(), xArea As Range, x&, Xm&, y&, Ym&, N&, Da As Date
Da = Application.Text([¬ì¥Ø¾lÃBªí!B1], "[$-404]e/m/d;@")
With Range([ÅçÃÒªí!U1], [ÅçÃÒªí!A65536].End(3))
Arr = .Value
Ym = UBound(Arr, 1)
Xm = UBound(Arr, 2)
Set xArea = .Resize(Ym, Xm + 1)
ReDim Brr(1 To Ym, 0)
For y = 2 To Ym
If CDate(Arr(y, 4)) > Da Then GoTo 101
N = N + 1: Brr(y, 0) = N
101: Next y
If N = Ym - 1 Then Exit Sub
xArea.Columns(Xm + 1) = Brr
End With
With xArea
.Sort KEY1:=.Item(Xm + 1), Order1:=xlAscending, Header:=xlYes
.Rows(N + 2 & ":" & Ym).Delete
.Columns(Xm + 1).Delete
.Sort _
KEY1:=[B1], Order1:=xlAscending, _
Key2:=[C1], Order2:=xlAscending, _
key3:=[D1], Order3:=xlAscending, _
Header:=xlYes, Orientation:=xlTopToBottom
End With
End Sub |
|