- ©«¤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
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-12-7 11:34 ½s¿è
¦^´_ 3# ¬PªÅÉ@¦ÐÁl
ÁÂÁ«e½ú¦^´_!½Ð¸Õ¸Õ¬Ý
«á¾ÇÂǦ¹ÃD½m²ß°}¦C»P¦r¨å,¾Ç¨ì«Ü¦hª¾ÃÑ,ÁÂÁÂ
1.¤U¸üÀÉ®×
¦æ¬F°|¤H¨ÆÁ`³B©xºô:
https://www.dgpa.gov.tw
112¦~¿ì¤½¤é¾äªí.xls¤U¸ü:
https://www.dgpa.gov.tw/FileConversion?filename=dgpa/files/202206/e71dbdb7-5339-48a7-b11e-172b2875df1e.xls&nfix=&name=112%E5%B9%B4%E8%BE%A6%E5%85%AC%E6%97%A5%E6%9B%86%E8%A1%A8.xls
2.±N¤U¦Cµ{¦¡½X©ñ¤JVBA§@°õ¦æ
¤U¸üÀÉ®×,¥¼°õ¦æ:
°õ¦æ«á:
Option Explicit
Sub ¤W¯Z¤é_°²¤é_¸É¯Z¤é()
Dim Brr, Sh1, V, xA, xR, Z, P, W, i&, n&, Ch$, y%, ymd As Date
Dim X&(4)
Set W = CreateObject("Scripting.Dictionary")
Set Z = CreateObject("Scripting.Dictionary")
Set P = CreateObject("Scripting.Dictionary")
Set Sh1 = Sheets("Sheet1")
Set Brr = Range(Sh1.[A1], Sh1.UsedRange)
Sh1.[AA:AH].ClearContents
V = Split(",¤@,¤G,¤T,¥|,¤,¤»,¤C,¤K,¤E,¤Q,¤Q¤@,¤Q¤G", ",")
For i = 1 To 12
Z(V(i) & "¤ë") = i
Next
For Each xR In Brr
If xR Like "*¦è¤¸####¦~*" Then y = Mid(xR, InStr(xR, "¦è¤¸") + 2, 4)
Ch = xR & xR.Item(, 2) & xR.Item(, 3)
If Z.Exists(Ch) And xR.Item(, 3) <> "" Then
Set W(Ch) = xR.Item(1, -1).Resize(14, 7)
End If
Next
Z.Add "«D©P¥ð¤G¤é°²¤é", 1
Z.Add "©P¥ð¤G¤é", 3
Z.Add "¤W¯Z¤é", 5
Z.Add "¸É¯Z¤é", 7
For Each xR In W.KEYS
For Each xA In W(xR)
If IsNumeric(xA) And xA <> "" Then
ymd = y & "/" & Z(xR) & "/" & xA
If xA.Interior.ColorIndex <> -4142 Then
If Format(ymd, "w") > 1 And Format(ymd, "w") < 7 Then
P(ymd) = "«D©P¥ð¤G¤é°²¤é"
X(1) = X(1) + 1
W(ymd) = X(1)
Else
P(ymd) = "©P¥ð¤G¤é"
X(2) = X(2) + 1
W(ymd) = X(2)
End If
ElseIf Format(ymd, "w") > 1 And Format(ymd, "w") < 7 Then
P(ymd) = "¤W¯Z¤é"
X(3) = X(3) + 1
W(ymd) = X(3)
n = n + 1
Else
P(ymd) = "¸É¯Z¤é"
X(4) = X(4) + 1
W(ymd) = X(4)
End If
End If
Next
Next
ReDim Brr(1 To n, 1 To 8)
For Each xR In P.KEYS
ymd = xR
Brr(W(ymd), Z(P(ymd))) = ymd
Brr(W(ymd), Z(P(ymd)) + 1) = Format(ymd, "aaaa")
Next
[AA1].Resize(1, 8) = [{"«D©P¥ð¤G¤é°²¤é","","©P¥ð¤G¤é","","¤W¯Z¤é","","¸É¯Z¤é",""}]
[AA2].Resize(n, 8) = Brr
Sh1.[AA:AH].Columns.AutoFit
[AA1].CurrentRegion.Borders.LineStyle = 1
Set W = Nothing: Set Z = Nothing: Set P = Nothing: Set Brr = Nothing
Erase V, X
End Sub |
|