- ©«¤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-3
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-11-29 14:00 ½s¿è
¦^´_ 1# ¬PªÅÉ@¦ÐÁl
ÁÂÁ«e½úµoªí¦¹¥DÃD»P½d¨Ò
ÁÂÁ samwang«e½ú´£¨Ñ¸Ñ¨M¤èªk»P¸Ñ»¡,«á¾Ç¾Ç²ß«á¥Î¬Û¦P¤èªk,¤£¦Pªº³¯z¤è¦¡½m²ß°}¦C»P¦r¨å
¤ß±oµù¸Ñ¦p¤U,½Ð¦U¦ì«e½ú¦A«ü¾É
Option Explicit
Sub TEST()
Application.DisplayAlerts = False
Dim Brr, C&, x, V, xD, Sh, Tym$, mm&
'¡ô«Å§iÅܼÆ
Set Sh = Sheets("P-012-02A-¹w©w¤u§@¶i«×ªí")
'¡ô¥OSh ¬O¤u§@ªí(¥H¤UºÙ:¶i«×ªí),¦WºÙ¬O "P-012-02A-¹w©w¤u§@¶i«×ªí"
Set xD = CreateObject("Scripting.Dictionary")
'¡ô¥OxD ¬O¦r¨å
C = Sh.UsedRange.EntireColumn.Columns.Count
'¡ô¥OC ¬O¦³¨Ï¥ÎÀx¦s®æ½d³òªº³Ì¤jÄæ¦ì¼Æ
Brr = Sh.Range(Sh.Cells(5, 1), Sh.Cells(5, C))
'¡ô¥OBrr ¬O¤Gºû°}¦C!ˤJ±q¶i«×ªí[A5]¨ì²Ä¤¦C³Ì«á¤@ÄæÀx¦s®æ½d³òÀx¦s®æÈ
For x = 1 To UBound(Brr, 2)
'¡ô³]¶¶°j°é±q1¨ìBrr°}¦C¾î¦VÄæ¦ìªº³Ì¤jÄæ¦ì¼Æ
If IsDate(Brr(1, x)) Then
'¡ô¦pªG°j°é°}¦CȬO¤é´Á??
Tym = Format(Brr(1, x), "yyyy/mm")
'¡ô¦pªGIf±ø¥ó¦¨¥ß!¥OTym¦r¦êÅÜ¼Æ ¬O°j°é°}¦CÈÂà¤Æ¬° ¥|½X¦~¥[ "/" ²Å¸¹¥[ ¨â½X¤ëªº¦r¦ê
If xD.Exists(Tym) = Empty Then
'¡ô¦pªG¥Î Tym¦r¦êÅܼƬd¹î¦r¨å¸Ì¬Oªì©lÈ
Set xD(Tym) = Sh.Cells(4, x)
'¡ô¥OTym¦r¦êÅܼƬO xD¦r¨å¸Ìªºkey,Item¬O¶i«×ªí²Ä4¦C.°j°éÄ檺Àx¦s®æ
Else
Set xD(Tym) = Union(xD(Tym), Sh.Cells(4, x))
'¡ô¥OTym¦r¦êÅܼƬO xD¦r¨å¸Ìªºkey,
'Item¬O쥻Item¸ÌªºÀx¦s®æ¦A¥[¤J ¶i«×ªí²Ä4¦C.°j°éÄ檺Àx¦s®æªº Àx¦s®æ¶°
End If
End If
Next
V = Split(",¤@,¤G,¤T,¥|,¤,¤»,¤C,¤K,¤E,¤Q,¤Q¤@,¤Q¤G", ",")
'¡ô¥OV¬O¦r¦ê¥Î ","²Å¸¹¤À³Îªº¤@ºû°}¦C
For Each x In xD.Keys
'¡ô³]¶¶°j°é!¥Ox¬O xD¦r¨åKeysªº¤@û
xD(x).UnMerge
'¡ôxD¦r¨å¸Ì°j°éKey¹ïÀ³ªº Àx¦s®æ¶°¨ú®ø¦X¨ÖÀx¦s®æ
xD(x).Merge
'¡ôxD¦r¨å¸Ì°j°éKey¹ïÀ³ªº Àx¦s®æ¶°°õ¦æ¦X¨ÖÀx¦s®æ
xD(x).HorizontalAlignment = xlCenter
'¡ôxD¦r¨å¸Ì°j°éKey¹ïÀ³ªº Àx¦s®æ¶°¤å¦r¥ª¥k¸m¤¤
mm = Split(x, "/")(1)
'¡ô¥Omm&¼Æ¦rÅܼƬOx¥Î "/"²Å¸¹©î¸Ñªº¤@ºû°}¦C!¨ú²Ä 1Ó¦r¦êÂন¼Æ¦r(¤ë¥÷)
'¦]¬°¦¹¤@ºû°}¦C¤¸¯À¬O¦r¦ê,¦]«Å§i¬Omm¼Æ¦r!©Ò¥H¦r¦ê·|Åܦ¨¼Æ¦r
'ps:¦¹¤@ºû°}¦Cªº²Ä0Ó¦r¦ê¬O(¥|½X¦~¤À)
xD(x)(1) = V(mm) & "¤ë"
'¡ôxD¦r¨å¸Ì°j°éKey¹ïÀ³ªº Àx¦s®æ¶°²Ä¤@®æ¶ñ¤J¤å¦r:
'¤å¦r¬O¥Îmm¼Æ¦r§ì¨ú V¤@ºû°}¦C¸Ì¹ïÀ³ªº°ê¦r¼Æ¦r¦ê,«á±¦A¥[ "¤ë"¦r
Next
Set Brr = Nothing
Set xD = Nothing
End Sub |
|