ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

EXCEL°ê©w°²¤é¦Û°Ê§ó·s

¥»©«³Ì«á¥Ñ 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

TOP

¦^´_ 2# Andy2483
·PÁÂAndy2483«e½ú¦^ÂÐ
Àɮצpªþ¥ó
¤H­û°O¿ýªí ´ú¸Õ 20221206.rar (14.78 KB)

¥Ø«eªí³æ¬O»s§@¸U¦~¾úªº¼Ë¦¡
¥Î¨Ó°O¿ý¨C¤é¤¤À\¤H­û¼Æ¶q
¦ý¥u­n·sªº£¸¦~´N­n¦Û¤v¥Î¤â°Ê§ó·s¸É¯Z¤é¤Î¥ð°²¤é
·Q¨Ì·Ó¦æ¬F°|¤½§i¦æ¨Æ¾äªº¸É¯Z¤é¤Î¥ð°²¤é¶i¦æ§ó·s
¤£ª¾¹D¬O§_¥i¦æ©O¡H

p.s¤p§ÌÅv­­¤£¨¬¡AµLªk¶Kºô§}¡A­n³Â·Ð¦U¦ì¤j¤j¬d¤@¤U¬F°|¤½§i¦æ¨Æ¾ä¡A¤£¦n·N«ä

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-12-6 12:11 ½s¿è

¦^´_ 1# ¬PªÅÉ@¦ÐÁl


    ÁÂÁ«e½úµoªí¦¹¥DÃD
½×¾Â¦³¹ïºô­¶§ì¨ú«Ü¼F®`ªº«e½ú!
¦pªG¤W¶Ç½d¨ÒÀÉ(¸U¦~¾ä©Î¬O±M®×ªºÀÉ®×)»P§iª¾·Q­n¥Î­þ­Ó¦æ¨Æ¾äºô­¶ºô§}°µ§ó·s,
¤ñ¸û¦³¾÷·|¦³¤è®×¥i¸Ñ¨M

TOP

        ÀR«ä¦Û¦b : ¨ü¤HÂI¤ô¤§®¦¡A¶··í´é¬u¥H³ø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD