ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Array¯x°},¦p¦ó¨ú¥XAR(1)¸Ìªº²Ä5­Ó­Èµ¥µ¥

[µo°Ý] Array¯x°},¦p¦ó¨ú¥XAR(1)¸Ìªº²Ä5­Ó­Èµ¥µ¥

½Ð±Ð¤j¤j:
­Ó¤H¦b½m²ß¯x°}¥Îªk
Sub Transpose2()
    Dim AR()
    ReDim Preserve AR(k)
        AR(k) = Sheets("test1").Range(Cells(1, 1), Cells(10, 1)).Value
        AR(0) = Sheets("test1").Range(Cells(1, 1), Cells(10, 1)).Value
        k = k + 1
        ReDim Preserve AR(k)
        AR(1) = Sheets("test1").Range(Cells(1, 2), Cells(10, 2)).Value
        k = k + 1
        ReDim Preserve AR(k)
        AR(2) = Sheets("test1").Range(Cells(1, 3), Cells(10, 3)).Value
        k = k + 1
        ReDim Preserve AR(k)
     With Sheets("test1")
        AR = Application.Transpose(Application.Transpose(AR))    ¦¹¥yerror   why?

        .Cells(1, 10).Resize(UBound(AR(0))) = AR(0)
        .Cells(1, 11).Resize(UBound(AR(1))) = AR(1)
        .Cells(1, 12).Resize(UBound(AR(2))) = AR(2)
        .Cells(1, 13).Resize(UBound(AR(3))) = AR(3)
    End With
End Sub
½Ð±Ð¤j¤j
        ¤S¦p¦ó¨ú¥XAR(1)¸Ìªº²Ä5­Ó­È
       ¤S¦p¦ó¨ú¥XAR(2)¸Ìªº²Ä6­Ó­Èµ¥µ¥??

¦^´_ 1# yangjie

§A¼gªº»yªk©M¬[ºc³£¤£¹ï¡I
µ{¦¡¤]¤£¥Î³o¼Ë¸¨¸¨ªø¡I
  1. Sub Transpose2()
  2. AR = Sheets("test1").Range(Cells(1, 1), Cells(10, 3)).Value'¤U­±µù¸Ñªº³¡¥÷¬O§A­ì¦³ªºµ{¦¡¡A¥u­n³o¤@¦C´N¥i¥H§¹¦¨
  3.         'AR(k) = Sheets("test1").Range(Cells(1, 1), Cells(10, 1)).Value
  4.         'AR(0) = Sheets("test1").Range(Cells(1, 1), Cells(10, 1)).Value
  5.         'k = k + 1
  6.         'ReDim Preserve AR(k)
  7.         'AR(1) = Sheets("test1").Range(Cells(1, 2), Cells(10, 2)).Value
  8.        ' k = k + 1
  9.         'ReDim Preserve AR(k)
  10.         'AR(2) = Sheets("test1").Range(Cells(1, 3), Cells(10, 3)).Value


  11. Cells(1, 10).Resize(3, UBound(AR, 1)) = ""     '²M°£
  12. Cells(5, 10).Resize(UBound(AR, 1), 3) = ""'   '²M°£
  13. Cells(1, 10).Resize(3, UBound(AR, 1)) = Application.Transpose(AR)'³o¦C¬O±qJ1Äæ¨ìS3¡A©¹¾îªº¤è¦V¶K¤W
  14. Cells(5, 10).Resize(UBound(AR, 1), 3) = AR'³o¦C¬O±qJ5¨ìL14©M­ì¨Óªº¤è¦V¤@¼Ë
  15. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# yangjie
¦p¤U¹ÏÅã¥Ü
   

TOP

¦^´_ 1# yangjie

¦A¶K¤@±i¸ÑÄÀµ¹§A
   

TOP

¦^´_ 3# lpk187
ÁÂÁÂlpk187
AR = Sheets("test1").Range(Cells(1, 1), Cells(10, 3)).Value
Cells(5, 10).Resize(UBound(AR, 1), 3) = "" '   '²M°£
Cells(5, 10).Resize(UBound(AR, 1), 3) = AR
if ......
     ­Y¾ã­Ó§PŪ¤§«á¤U¡A
     »Ý­n¦bcells(5,15)¤U¼g¤JBÄ椧­È
endif
    À³¦p¦ó¼g»yªk

TOP

¥»©«³Ì«á¥Ñ lpk187 ©ó 2015-6-12 14:53 ½s¿è

¦^´_ 5# yangjie


    ar = Sheets("test1").Range(Cells(1, 1), Cells(10, 3)).Value 'Ū¨úA1¨ìC10
For N = 1 To 10
    If .....then
          Cells(5 , 15) = ar(N, 2) '³o¸Ìªº ar(N, 2)¬O«üBÄ檺²ÄN¦C
   end if
Next

TOP

¦^´_ 6# lpk187
¤F
ÁÂÁÂ

TOP

¦^´_ 5# yangjie

¨ä¹ê¤£­n§â°}¦C»{¬°«Ü½ÆÂø¡A¥HÀx¦s®æ¨Ó»¡°}¦C¡AÀx¦s®æ´N¬O¤@­Ó2ºû°}¦C¡A©Ò¥H·í§Ú­Ì§â½d³ò³]¦¨°}¦C®É¤]¬O¤@­Ó2ºû°}¦C
¨Ò¦p ar(¦C,Äæ)
¦ý°²­Y¥u¬O¦³1ºû°}¦C
´N¤£¯àª½±µ¥Î¹³ar=range("A1:C10")³oºØ¤è¦¡¥hŪ¨ú
¤è¦¡¦p¤U¡G
Ū¨ì¤@ºû°}¦C
Dim ar(1 to 10)
for N=1 to 10
    ar(N)=cells(N,1)
next
...
¼g¤J¨ìÀx¦s®æ
for x=1 to 10
cells(x,10)=ar(X)
next

TOP

¦^´_ 8# lpk187
ÁÂÁ«ü¾É

TOP

        ÀR«ä¦Û¦b : ¤H­nª¾ºÖ¡B±¤ºÖ¡B¦A³yºÖ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD