- ©«¤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 ©ó 2023-2-15 08:11 ½s¿è
¦^´_ 3# av8d
ÁÂÁ«e½ú¦^´_
«á¾Ç¤µ¤Ñ½Æ²ß¤F¤@¤U¨Ã§@¤ß±oµù¸Ñ,½Ð«e½ú°Ñ¦Ò
Option Explicit
Sub TEST()
Dim Arr, N&, i&, j&
'¡ô«Å§iÅܼÆ:Arr¬O³q¥Î«¬ÅܼÆ,(N,i,j)¬Oªø¾ã¼ÆÅܼÆ
Arr = Range([D1], Cells(ActiveSheet.UsedRange.Rows.Count, "A"))
'¡ô¥OArr³o³q¥Î«¬ÅܼƬO¤Gºû°}¦C,¥H²{ªí[D1]¨ìAÄæ/¨Ï¥Î¦CÀx¦s®æ,³o¤è¥¿½d³òÀx¦s®æÈˤJ
'PS:¨Ï¥Î¦C:¤w¨Ï¥ÎÀx¦s®æÂX®i¬°³Ì¤p¤è¥¿½d³òÀx¦s®æªº¦C¼Æ
For i = 2 To UBound(Arr)
'¡ô³]¶¶°j°é!i±q2¨ì Arr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹¼Æ
N = N + 1: Arr(N, 1) = ""
'¡ô¥ON³oªø¾ã¼ÆÅܼƲ֥[ 1 :¥ONÅܼƦC²Ä1ÄæArr°}¦CȬOªÅ¦r¤¸
For j = 1 To UBound(Arr, 2)
'¡ô³]¶¶°j°é!j±q2¨ì Arr°}¦C¾î¦V³Ì¤j¯Á¤ÞÄ渹¼Æ
If Trim(Arr(i, j)) <> "" Then
'¡ô¦pªGi°j°é¦C²Äj°j°éÄæArr°}¦CÈ¥hÀY§ÀªÅ¥Õ¦r¤¸«á¤£¬OªÅ¦r¤¸ ??
If Arr(N, 1) = "" Then
'¡ô¦pªGNÅܼƦC²Ä1°j°éÄæArr°}¦CȬOªÅ¦r¤¸??
Arr(N, 1) = "'" & Trim(Arr(i, j))
'¡ô¥ONÅܼƦC²Ä1°j°éÄæArr°}¦CȬO ³æ¤Þ¸¹,
'³s±µi°j°é¦C²Äj°j°éÄæArr°}¦CÈ¥hÀY§ÀªÅ¥Õ¦r¤¸ªº·s¦r¦ê
Else
Arr(N, 1) = Arr(N, 1) & "," & Trim(Arr(i, j))
'¡ô§_«h¥ONÅܼƦC²Ä1°j°éÄæArr°}¦CȬO ¦Û¨,
'³s±µ","²Å¸¹,¦A³s±µi°j°é¦C²Äj°j°éÄæArr°}¦CÈ¥hÀY§ÀªÅ¥Õ¦r¤¸ªº·s¦r¦ê
End If
End If
Next
Next
[E2].Resize(N, 1) = Arr
'¡ô¥O[E2]ÂX®i¦V¤UNÅܼƦC,¦V¥k¤£ÂX®iªº½d³òÀx¦s®æÈ,¥HArr°}¦Cȱa¤J
Set Arr = Nothing
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|