- ©«¤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-11-28
|
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½Æ²ß¬Q¤Ñªº¾Ç²ß¤è®×,¤è®×¾Ç²ß¤ß±oµù¸Ñ¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð
Option Explicit
Sub TEST()
Application.ScreenUpdating = False
'¡ô¥O¿Ã¹õ¼È¤£ÀHµÛµ{§Ç°µÅܤÆ
Dim Brr, Z, i&, T$, PH$, FN$, xB As Workbook, Sh As Worksheet
'¡ô«Å§iÅܼÆ($¬O¦r¦êÅܼÆ,&¬Oªø¾ã¼Æ,¨S¦³²Å¸¹ªº¬O³q¥Î«¬ÅܼÆ)
Set Z = CreateObject("Scripting.Dictionary")
'¡ô¥OZÅܼƬO ¦r¨å
PH = ThisWorkbook.Path: FN = "²§°Êªí±Æ§Ç.xlsm"
'¡ô¥OPHÅܼƬO ¥»Àɸê®Æ§¨¦ì§},¥OFNÅܼƬO «ü©wÀɦW(¸ê®Æªí)
On Error Resume Next
'¡ô¥Oµ{§Ç¼È¹J¨ì¿ù»~´NÄ~Äò°õ¦æ¤UÓµ{§Ç,¤£n°±¤U¨Ó±Æ¿ù
Set xB = Workbooks(FN): Set Sh = xB.Sheets("²§°Êªí±Æ§Ç")
'¡ô¥OxBÅܼƬO ¬¡¶Ã¯("²§°Êªí±Æ§Ç.xlsm"),¥OShÅܼƬO¨ä¤u§@ªí
Brr = Range(Sh.[E1], Sh.[A65536].End(3))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HA~EÄæÀx¦s®æȱa¤J°}¦C¤¤
On Error GoTo 0
'¡ô¥Oµ{§Ç«ì´_¹J¨ì¿ù»~´N°±¤U¨Ó±Æ¿ù
'³o¬q¤£±Æ¿ùªºµ{§Ç¬O¬°¤F "²§°Êªí±Æ§Ç.xlsm"³Q¶}±Òªº±¡¹Ò¤U,
'ÅýBrr¥i¥H¸Ë¶i°}¦CÈ
'¦pªGÀɮרS¦³³Q¶}±Òªº±¡ªp,µ{§Ç´N·|¸õ¹L³o¨Çµ{§Ç,Ä~Äò¤U¦æ
If xB Is Nothing Then
'¡ô¦pªGxBÅܼÆÁÙ¨S¦³¸Ë¤J¬¡¶Ã¯("²§°Êªí±Æ§Ç.xlsm")??
Set xB = Workbooks.Open(PH & "\" & FN)
'¡ô¥O¶}±Ò«ü©w¸ô®|¤UªºÀÉ®×,¨Ã¥OxBÅܼƬO¦¹¬¡¶Ã¯
Brr = Range([²§°Êªí±Æ§Ç!E1], [²§°Êªí±Æ§Ç!A65536].End(3))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HA~EÄæÀx¦s®æȱa¤J°}¦C¤¤
xB.Close 0
'¡ô¥O¬¡¶Ã¯¤£¦sÀÉÃö³¬
End If
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é
T = Brr(i, 2): If T = "" Then GoTo i00
'¡ô¥OTÅܼƬO °j°é¦C²Ä2ÄæBrr°}¦CÈ,¦pªGTÅܼƬOªÅªº!
'¬O´N¸õ¨ì¼Ð¥Üi00¦ì¸mÄ~Äò°õ¦æ
If Z(T) = "" Then
'¡ô¦pªG¥HTÅܼƬdZ¦r¨å±oitemȬOªÅ¦r¤¸?
Z(T) = Brr(i, 3) & " ¢i " & Brr(i, 4)
'¡ô¬O´N¥O¦bZ¦r¨å¸ÌªºTÅܼÆkey ªºitem´«¦¨·s¦r¦ê
'·s¦r¦ê:°j°é¦C²Ä3ÄæBrr°}¦Cȳs±µ " ¢i "¦A³s±µ °j°é¦C²Ä4ÄæBrr°}¦CÈ,
'¦¨¬°·s¦r¦ê,©ñ¦^Z¦r¨å¸Ì
Else
Z(T) = Z(T) & vbLf & Brr(i, 3) & " ¢i " & Brr(i, 4)
'¡ô§_«h(TÅܼÆkey ªºitemȤw¸g¦³¦r¦ê!)
'¥Oitem³s±µ´«¦æ¦A³s±µ °j°é¦C²Ä3ÄæBrr°}¦Cȳs±µ " ¢i "¦A³s±µ
'°j°é¦C²Ä4ÄæBrr°}¦CȦ¨¬°·s¦r¦ê,©ñ¦^Z¦r¨å¸Ì
End If
i00: Next
Brr = Range([±M®×!D1], [±M®×!D65536].End(3))
'¡ô¥OBrrÅܼƴ«¸Ëµ²ªGªíªºDÄæÀx¦s®æÈ,¨ÌµM¬O ¤Gºû°}¦C
'PS:Brr«Å§i¬O³q¥Î«¬ÅܼÆ,¥i¥H¥ô·N=´«¸Ë¸ê®Æ ©ÎSet Brr = ª«¥ó
[D:D].ClearComments
'¡ô¥ODÄ檺µù¸Ñ²M°£
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é
If Brr(i, 1) = "" Or Z(Brr(i, 1) & "") = "" Then GoTo i01
'¡ô±Æ°£ªÅ®æ©Î¦r¨å¸Ìitem¬OªÅ¦r¤¸ªº¶µ¥Ø,¸õ¨ì¼Ð¥Üi01¦ì¸mÄ~Äò°õ¦æ
Cells(i, 4).AddComment
'¡ô¥Oi°j°é¼Æ¦CDÄæÀx¦s®æ´¡¤Jµù¸Ñ
Cells(i, 4).Comment.Text Text:=Z(Brr(i, 1) & "")
'¡ô¥Oi°j°é¼Æ¦CDÄæÀx¦s®æªºµù¸Ñ¤å¦r¬O °j°éBrr°}¦CȬdZ¦r¨å±oitemÈ
Cells(i, 4).Comment.Shape.TextFrame.Characters.Font.Size = 16
'¡ô¥Oi°j°é¼Æ¦CDÄæÀx¦s®æªºµù¸Ñ¤å¦r¤j¤p¬° 16
Cells(i, 4).Comment.Shape.DrawingObject.AutoSize = True
'¡ô¥Oi°j°é¼Æ¦CDÄæÀx¦s®æªºµù¸Ñ®Ø¦Û°ÊÁY©ñ
i01: Next
Set Z = Nothing: Erase Brr: Set xB = Nothing: Set Sh = Nothing
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|