- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 3# melvinhsu1105
¬O³o¼Ë¶ý?- Option Explicit
- Sub Ex()
- Dim AR(), C%, i%, ii%
- ReDim AR(0) 'ReDim:«·s°t¸m°ÊºA°}¦CÅܼƪºÀx¦sªÅ¶¡ ->0¨ì0
- With ActiveSheet
- C = .[B1].End(xlToRight).Column '¨úªº:B1©¹¥k³sÄò¸ê®ÆªíÀY³Ì«áªºÄæ¦ì¼Æ
- AR(0) = .Range("B1", .Cells(1, C)).Value '«ü©w:°}¦Cªº¤¸¯ÀÈ
- For i = 2 To .Cells(2, "A").End(xlDown).Row '°j°é:±qA2¶}©l©¹¤Uª½¨ì¨S¸ê®Æªº¦C¦ì
- For ii = 1 To .Cells(i, "A").Value '°j°é:±q1¶}©l¨ì.Cells(i, "A").Value =½Æ»sªºµ§¼Æ
- ReDim Preserve AR(UBound(AR) + 1) 'ReDim:«·s°t¸m°ÊºA°}¦CÅܼƪºÀx¦sªÅ¶¡->즳ºû¼Æ+1
- 'Preserve:·í§ïÅÜ즳°}¦C³Ì«á¤@ºûªº¤j¤p®É¡A¤´µM«O¦³ì¨Óªº¸ê®ÆªºÃöÁä¦r¡C
- 'UBound:ªí¥Ü«ü©w°}¦C¬Yºû³Ì¤j¥i¨Ï¥Îªº°}¦C¯Á¤Þ
- AR(UBound(AR)) = .Range(.Cells(i, "B"), .Cells(i, C)).Value '«ü©w:°}¦C³Ì¤jªº¤¸¯ÀÈ
- Next
- Next
- End With
- With Workbooks.Add.Sheets(1).Range("A1") 'With: ¦b¤@Ó³æ¤@ª«¥ó©Î¤@ӨϥΪ̦Ûq«¬ºA¤W°õ¦æ¤@¨t¦Cªº³¯z¦¡¡C
- For i = 0 To UBound(AR) '°j°é:±qARªº²Ä1Ó¤¸¯À(0)¨ìARªº³Ì¤j¤¸¯ÀUBound(AR)
- .Offset(i).Resize(, C - 1) = AR(i) '.Offset(i):¦b¦¹iªí©¹¤Uªº¦C¼Æ
- '.Resize(, C - 1): ÂX¥Rªº½d³ò¬°(1¦C,C - 1Äæ)=°}¦C¤¸¯ÀªºÈ
- Next
- End With
- End Sub
½Æ»s¥N½X |
|