- ©«¤l
- 135
- ¥DÃD
- 19
- ºëµØ
- 0
- ¿n¤À
- 165
- ÂI¦W
- 0
- §@·~¨t²Î
- XP
- ³nÅ骩¥»
- 2003
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- »´ä
- µù¥U®É¶¡
- 2010-12-9
- ³Ì«áµn¿ý
- 2012-8-27
|
¥»©«³Ì«á¥Ñ FAlonso ©ó 2011-1-8 20:25 ½s¿è
Ãö©ótranspose°ÝÃD....
¨Ò¦pexcel¦³¦p¤U±Æ¦C
A B C D
1 r
2 e
3 s
4 t
±N¤@Ócolumnªº¦r³s¦ê:
transpose¤@¦¸
µ²ªG¬Or,e,s,t- Sub abc()
- Dim mystring
- mystring = Join(Application.Transpose(Range("A1:a4").Value), ",") 'ª`·N³o¸Ì¬O¤@Ócolumn¦ê
- Range("A10").Value = mystring
- End Sub
½Æ»s¥N½X ±N¤@Órowªº¦r³s¦ê:
transpose¤G¦¸
A B C D
1 r t u i- Sub abc()
- Dim mystring
- mystring = Join(Application.Transpose(Application.Transpose(Range("A1:D1"))), ",") 'ª`·N³o¸Ì¬O¤@Órow¦ê
- Range("A10").Value = mystring
- End Sub
½Æ»s¥N½X µ²ªG¬Or,t,u,i
¤µ¤é°µ¤F¤@ÂI¸Ô²Ó¬ã¨s,¬O¤gªk¤jÁå¿û
¥ý§â¥H¤Uµ{¦¡§Û¶iVBA- Sub check()
- Dim ar As Variant
- Dim i As Integer
- Set ar = [a1:a4] 'try [a1:d1] later
- For i = 1 To 6
- ar = Application.Transpose(ar)
- Next
- Set ar = Nothing
- End Sub
½Æ»s¥N½X ¥´¶}À˵ø->°Ï°ìÅܼƵøµ¡,¦A«öF8,³v¦æ°õ¦æ,Æ[¹îar°}ªº¸ê®Æ
¥ý¬Ý[a1:a4],¤@Ócolumnªºrange
¬O¤@Ó2D°}¦C(¬Ý¬õ¦â°é¤l), variant(1 to 4,1 to 1)
transpose¤@¦¸«á,Åܦ¨¤F¤@Ó1D°}¦C, variant(1 to 4),³oÓ¬O¥i¥H¶i¤Jjoin()µ{¦¡ªºªFªF
¤£½×¦A¦p¦ótranspose,³£¥u·|«ÂÐvariant(1 to 4,1 to 1) -> variant(1 to 4) -> variant(1 to 4,1 to 1) ³oÓ´`Àô
¦A¬Ý[a1:d1](¦Û¤v§âµ{¦¡×§ï),¤@Órowªºrange
¬O¤@Ó2D°}¦C, variant(1 to 1,1 to 4),³o¸Ì¤£¦Aprint screen¤F,¤j®a¦Û¤v¬Ý¬Ý
transpose¤@¦¸«á,Åܦ¨¥t¥~¤@Ó2D°}¦C,¥svariant(1 to 4,1 to 1),³o¼Ë¬O¤£¯à¶i¤Jjoinµ{¦¡
transpose²Ä¤G¦¸,«KÅܤFvariant(1 to 4),¥i¥H¤F!
¦ý¤§«áµL½×«çtranspose,³£¥u·|«ÂÐvariant(1 to 4,1 to 1) -> variant(1 to 4) -> variant(1 to 4,1 to 1) ³oÓ´`Àô,¥Ã»·¤£·|Åܦ^variant(1 to 1,1 to 4)³oÓ³]©w
¥´Ó¤ñ³ë,´Nµ¥¦p¤@Ó2-D rowªº°}¦C,º¥ýÅܤF"Ãþ¦ü"2-D columnªº§ÎºA,¦AÅÜ1-D array
¦Ó2-D column´N°¨¤WÅܤF1-D array
³o¼ËÀ³¸Ó¯à°÷¸ÑÄÀ¬°¤°»òrowntranspose¦h¤@¦¸,¦ýrow¬°¤°»ònº¥ýÅܦ¨column§Î,¤£n°Ý§Ú
³Ì«ád1.items¨º¦æ
¬Ý¥H¤U¨Ò¤l- Dim myrange As Range
- Dim i As Integer, k
- Set myobject = CreateObject("scripting.dictionary")
- myobject("A") = Array(1, 2)
- myobject("B") = Array(4, 5)
- myobject("C") = Array(7, 8)
- Set myrange = Worksheets("sheet2").Range("A1").Resize(3, 2)
- k = myobject.items
- k = Application.Transpose(Application.Transpose(k))
- myrange = k
½Æ»s¥N½X ¦b§¹¦¨myobject°t¸m«á,°Ï°ìÅܼƪºÅã¥Ü«ü¸Óª«¥ó©|¥¼¬Oarray(¨S¦³¨º¨Çvariant(x,y),¯Âºé¬O«Ü´²ªº¬[ºc)
§âmyobject.items¥s¥X¨Ó,«K¬Ý¨ìk¦³variant(0,2)ªº1D§ÎºA(3Ó¯Á¤Þ,"A","B","C")
¥´¶}kªº"+"Áä,·|¬Ý¨ìk(0),k(1),k(2)¦U¦Û³£¦³variant(0,1)ªº1D§ÎºA(§Y¨CÓ¯Á¤Þ¤¤ªº¨âӼƦrªºªí¥Ü)
transpose()¤@¦¸,«K·|¦¨¤@Óvariant(1 to 2,1 to 3)ªº2D°}¦C
¨ä¹ê¦¹®É¤w¸g¥i¥H¶K¤W®æ¤lÅo!¸Õ§âresize(3,2)Åܦ¨(2,3)¬Ý¬Ý!
¤£¹L¦]¬°§ÚÌ·Q±Æ¦¨
A B
1 1 2
2 4 5
3 7 8
©Ò¥H¦Atranspose¤@¦¸¦Ó¤w |
|