- ©«¤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
|
¦^´_ 3# PJChen
¦A¦¸ÁÂÁ«e½úµoªí¦¹¥DÃD,ÁÂÁ½׾Â
«á¾Ç½Æ²ßµ{¦¡½X°µ¤ß±oµù¸Ñ,½Ð«e½ú°Ñ¦Ò,½Ð¦U¦ì«e½ú«ü±Ð
,Option Explicit
Sub TEST()
Dim Brr, i&, j&, T$, T1$, xR As Range, Sh As Worksheet
'¡ô«Å§iÅܼÆ:Brr¬O³q¥Î«¬ÅܼÆ,(i,j)¬Oªø¾ã¼Æ,(T,T1)¬O¦r¦êÅܼÆ,
'xR¬OÀx¦s®æÅܼÆ,Sh¬O¤u§@ªíÅܼÆ
Set Sh = Sheets("mark")
'¡ô¥OSh³o¤u§@ªíÅܼƬO¦W¬° "mark"ªº¤u§@ªí
Set xR = Intersect(Sh.[J:AD], Sh.[J1].CurrentRegion.Offset(1, 0))
'¡ô¥OxR³oÀx¦s®æÅܼƬO ¨âÓ½d³òÀx¦s®æ¥æ¶°ªº½d³òÀx¦s®æ
'½d³ò1:"mark"¤u§@ªíªºJÄæ¨ìADÄ椧¶¡ªº©Ò¦³Àx¦s®æ
'½d³ò2:"mark"¤u§@ªíªº[J1]Àx¦s®æ¬Û¾F¦ê±µÀx¦s®æÂX®i³Ì¤p¤è¥¿½d³òªºÀx¦s®æ
Intersect(xR.Offset(1, 0), [AD:AD]).ClearContents
'¡ô¥O¨âÓ½d³òÀx¦s®æ¥æ¶°ªº½d³òÀx¦s®æ²M°£¨ä¤º®e
'½d³ò1:xRÅܼƦV¤U°¾²¾¤@¦Cªº½d³òÀx¦s®æ
'½d³ò2:ADÄæ¥þ³¡ªºÀx¦s®æ
Brr = xR
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥O¥HxRÅܼÆÈ(Àx¦s®æÈ)±a¤J°}¦C
For i = 1 To UBound(Brr) - 1
'¡ô³]¶¶°j°é!i±q 1¨ì Brr°}¦CÁa¦V²Ä2¤j¯Á¤Þ¦C¸¹
For j = 1 To UBound(Brr, 2) - 1
'¡ô³]¶¶°j°é!j±q 1¨ì Brr°}¦C¾î¦V²Ä2¤j¯Á¤ÞÄ渹
T = Brr(i, j)
'¡ô¥OT³o¦r¦êÅܼƬO i°j°é¦C²Äj°j°éÄ檺Brr°}¦CÈ
T1 = Replace(Replace(T1 & "," & T & ",", ",,", ","), ",,", ",")
'¡ô¥OT1³o¦r¦êÅܼƬO T1ÅܼƳs±µ³r¸¹,¦A³s±µTÅܼÆ,
'¦A³s±µ³r¸¹²Õ¦¨ªº·s¦r¦ê,³Ì«á¸g¹L¨â¦¸¦r¦ê¸m´««áªº¥þ·s¦r¦ê
'²Ä1¦¸¦r¦ê¸m´«¬O±N¦r¦ê¸Ìªº",,"Âù³r¸¹¸m´«¦¨","1Ó³r¸¹
'²Ä2¦¸¦r¦ê¸m´«¤]¬O±N¦r¦ê¸Ìªº",,"Âù³r¸¹¸m´«¦¨","1Ó³r¸¹
Next
Brr(i, 1) = Mid(Left(T1, Len(T1) - 1), 2): T1 = ""
'¡ô¥Oi°j°é¦C²Ä1ÄæBrr°}¦CȬO Â_±ËÂ÷¤§«á³Ñ¤Uªº¦r¦ê
'¥ýT1ÅܼƦr¦ê¨ú¥ª°¼ªº¦r¤¸,³Ì¥kÃ䪺¦r¤£¨ú,
'¤§«á¦A¨ú¥kÃ䪺¦r¤¸,³Ì¥ªÃ䪺¦r¤£¨ú,
'PS:´N¬O³Ì¥ª³Ì¥kªº³o¨âÓ¦r¤¸¤£n,¨ú¤¤¶¡ªº¦r¦ê
Next
With Intersect(Intersect(xR, [AD:AD]), Sh.[J1].CurrentRegion)
'¡ô¥H¤U¬OÃö©ó¨â¦¸Àx¦s®æ½d³ò¥æ¶°«áÀx¦s®æªºµ{§Ç
.Value = Brr: .Select
'¡ô¥O¨äÀx¦s®æȬO Brr°}¦CÈ,Brr°}¦C¶W¹L¸ÓÀx¦s®æ½d³òªºÈ¤£¥Î¥¦
End With
Set xR = Nothing: Set Sh = Nothing: Erase Brr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|