- ©«¤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-5
|
¦^´_ 1# johnny1680
ÁÂÁ«e½úµoªí¦¹¥DÃD»P½d¨Ò,ÁÂÁ¦U¦ì«e½ú«ü¾É
¤µ¤Ñ«á¾ÇÂǦ¹©«¾Ç²ß¨ì«Ü¦hª¾ÃÑ,½m²ß¨ì«Ü¦h¤èªk,¥H¤U¾Ç²ß¤ß±o½Ð¦U¦ì«e½ú«ü±Ð
°õ¦æ«e:
°õ¦æµ²ªG:
Option Explicit
Sub TEST_1()
Dim Brr, C%, j%, i&, xR As Range
'¡ô«Å§iÅܼÆ:Brr¬O³q¥Î«¬ÅܼÆ,(C,j)¬Oµu¾ã¼ÆÅܼÆ,
'i¬Oªø¾ã¼ÆÅܼÆ,xR¬OÀx¦s®æÅܼÆ
C = Cells(1, Columns.Count).End(xlToLeft).Column
'¡ô¥OC³oµu¾ã¼ÆÅܼƬO ²Ä1¦C³Ì¥k°¼¦³¤º®eÀx¦s®æÄ渹
If C <= 2 Then Exit Sub
'¡ô¦pªGCÅܼÆ<=2!´Nµ²§ôµ{¦¡°õ¦æ
Set xR = Range([A2], Cells(1, C))
'¡ô¥OxR³oÀx¦s®æÅܼƬO [A2]¨ì(²Ä1¦C²ÄCÅܼÆÄæÀx¦s®æ),
'¥OxR³oÀx¦s®æÅܼƬO³o½d³òÀx¦s®æ(ª«¥óÅܼÆ)
Brr = xR
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥HxRÅܼÆ(Àx¦s®æÈ)±a¤J
For i = 1 To UBound(Brr)
'¡ô³]¶¶°j°é!i±q1¨ìBrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¸¹¦C
For j = 1 To UBound(Brr, 2)
'¡ô³]¶¶°j°é!j±q1¨ìBrr°}¦C¾î¦V³Ì¤j¯Á¤Þ¸¹Äæ
Brr(i, j) = Format(Brr(i, j), "000|")
'¡ô¥Oi°j°é¦Cj°j°éÄæBrr°}¦CȬO«ü©w¤å¦r®æ¦¡ªº¦r¦ê
'«ü©w¤å¦r®æ¦¡ªº¦r¦ê:Yì¬O¼Æ¦r!´N¸É0¦¨3½X³s±µ"|"
Next
Next
With xR.Offset(4, 0)
'¡ô¥H¤U¬OÃö©óxRÅܼƦV¤U°¾²¾4¦C½d³òÀx¦s®æªºµ{§Ç
.Value = Brr
'¡ô¥O¸Ó½d³òÀx¦s®æȬOBrr°}¦CÈ
.Offset(0, 1).Sort KEY1:=.Item(2, 1), _
Order1:=1, Key2:=.Item(1), Order2:=1, _
Orientation:=xlLeftToRight
'¡ô¥O¸Ó½d³òÀx¦s®æ¦V¥k°¾²¾1Äæ½d³òÀx¦s®æ,
'°µ¨â¼h¦¸¾î¦V¶¶±Æ§Ç:
'²Ä1¼h¦¸¥H¸Ó½d³ò¤º¤U¤è2¦C²Ä1ÄæÀx¦s®æ¬°±Æ§Ç°ò·Ç,
'²Ä2¼h¦¸¥H¸Ó½d³ò¤º²Ä1®æÀx¦s®æ¬°±Æ§Ç°ò·Ç
.Replace "|*", "", Lookat:=xlPart
'¡ô¥O¸Ó½d³òÀx¦s®æÈ°µ¤å¦r¸m´«:
'±N"|"²Å¸¹(§t)¥k°¼ªº©Ò¦³¤å¦r ¸m´«¬°ªÅ¦r¤¸
End With
End Sub |
|