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

[µo°Ý] ¦p¦ó¦X¨Ö°}¦C

[µo°Ý] ¦p¦ó¦X¨Ö°}¦C

¥»©«³Ì«á¥Ñ sunnyso ©ó 2013-5-12 03:09 ½s¿è

½Ð±Ð¦U¦ì¤j¤j¡A°£¤F¥ÎFor¥H¥~¡AVBA¦³¨S¦³§ó²¼ä¦³®Äªº¤èªk¦X¨Ö°}¦C©O¡H

¨Ò¦p
  1.   |A1 B1 C1|
  2. A=|A2 B2 C2|
  3.   |A3 B3 C3|

  4. B=|A4 B4 C4|
  5.   |A5 B5 C5|

  6. C= A ++ B

  7.   |A1 B1 C1|
  8.   |A2 B2 C2|
  9. C=|A3 B3 C3|
  10.   |A4 B4 C4|
  11.   |A5 B5 C5|
½Æ»s¥N½X
ss

¦^´_ 1# sunnyso


    ¤j¤j±z¦n¡G
¤£ª¾¤Þ¥Îarray¬O§_
²Å¦X¤j¤jªº¶·¨D
c=array(a,b)

TOP

¦^´_ 1# sunnyso
  1. Option Explicit
  2. Sub EX()
  3.     Dim A As Variant, B As Variant, C As Variant, I As Integer
  4.     A = Array(Array("A1", "B1", "C1"), Array("A2", "B2", "C2"), Array("A3", "B3", "C3"))
  5.     B = Array(Array("A4", "B4", "C4"), Array("A5", "B5", "C5"))
  6.     C = A
  7.     For I = 0 To UBound(B)
  8.         ReDim Preserve C(0 To UBound(C) + 1)
  9.         'ReDim ³¯­z¦¡  ¦bµ{§Ç¼h¦¸¤¤¥Î¨Ó­«·s°t¸m°ÊºA°}¦CÅܼƪºÀx¦sªÅ¶¡¡C
  10.         'Preserve  ·í§ïÅܭ즳°}¦C³Ì«á¤@ºûªº¤j¤p®É¡A¤´µM«O¦³­ì¨Óªº¸ê®ÆªºÃöÁä¦r
  11.         C(UBound(C)) = B(I)
  12.     Next
  13. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 3# GBKEE

·PÁ¤j¤j, ½Ð°Ý¦³¨S¦³¤£¥Î°j°éªº¤èªk.
ss

TOP

¦^´_ 4# sunnyso
«Ý§Ú¦A·Q¤@·Q¦³µL!!!
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# sunnyso
¨â­Ó¤GºûArray¡A¤£¨Ï¥ÎFor¡A¦X¨Ö¬°¤@­Ó
§Ú¥u·Qªº¨ì­É¥Î¤u§@ªí...
§â¨â­Ó Array ¥á¨ìÀx¦s®æ¦A®³¥X¨Ó...

¦ý¬O§Ú·Pı³o¼Ë¤ñFor¨S¦³®Ä²v

TOP

¦^´_ 6# stillfish00

·PÁÂ, ¥i§_´£¨Ñcode°Ñ¦Ò

thanks
ss

TOP

¦^´_ 7# sunnyso
  1. Sub EXE()
  2.     Dim A As Variant, B As Variant, C As Variant, D As Variant, I As Integer
  3.     A = Array(Array("A1", "B1", "C1"), Array("A2", "B2", "C2"), Array("A3", "B3", "C3"))
  4.     B = Array(Array("A4", "B4", "C4"), Array("A5", "B5", "C5"))
  5.     [A1].Resize(UBound(A) + 1, 3) = Application.Transpose(Application.Transpose(A)) '°}¦CA¼g¤J¤u§@ªí
  6.     [A1].Offset(UBound(A) + 1).Resize(UBound(B) + 1, 3) = Application.Transpose(Application.Transpose(B)) '°}¦CB¼g¤J¤u§@ªí
  7.     D = Range("A1").CurrentRegion.Value '±NÀx¦s®æ¸ê®Æ¦s¦¨·s°}¦C
  8.     Range("A1").CurrentRegion = ""
  9.     [A1].Resize(UBound(D, 1), UBound(D, 2)) = D '¼g¦^¤u§@ªí
  10. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ c_c_lai ©ó 2013-5-18 09:18 ½s¿è

¦^´_ 7# sunnyso
¦^´_ 5# GBKEE
¦^´_ 8# Hsieh
ÁÂÁ GBKEE ¥H¤Î Hsieh ¨â¦ì¤j¤jªº½d¨Ò¡C
¯÷±N¥¦­Ìµyµy¤Þ¥Î¡G
  1. Option Explicit

  2. Sub EX()            '  GBKEE
  3.     Dim A As Variant, B As Variant, C As Variant, I As Integer
  4.     A = Array(Array("A1", "B1", "C1"), Array("A2", "B2", "C2") ,Array("A3", "B3", "C3"), Array("A4", "B4", "C4"))
  5.     B = Array(Array("A5", "B5", "C5"), Array("A6", "B6", "C6"))
  6.     C = A
  7.     For I = 0 To UBound(B)
  8.         ReDim Preserve C(0 To UBound(C) + 1)
  9.         'ReDim ³¯­z¦¡  ¦bµ{§Ç¼h¦¸¤¤¥Î¨Ó­«·s°t¸m°ÊºA°}¦CÅܼƪºÀx¦sªÅ¶¡¡C
  10.         'Preserve  ·í§ïÅܭ즳°}¦C³Ì«á¤@ºûªº¤j¤p®É¡A¤´µM«O¦³­ì¨Óªº¸ê®ÆªºÃöÁä¦r
  11.         C(UBound(C)) = B(I)
  12.     Next
  13.     Range("A1").CurrentRegion = ""
  14.     '  UBound(C) = 5,  UBound(C(0)) = 2
  15.     [A1].Resize(UBound(C) + 1, UBound(C(0)) + 1) = Application.Transpose(Application.Transpose(C))                       ' °}¦CA¼g¤J¤u§@ªí
  16. End Sub

  17. Sub EX2()             '  Hsieh
  18.     Dim A As Variant, B As Variant, C As Variant, D As Variant, I As Integer

  19.     Range("A1").CurrentRegion = ""
  20.     A = Array(Array("A1", "B1", "C1"), Array("A2", "B2", "C2"), Array("A3", "B3", "C3"), Array("A4", "B4", "C4"))
  21.     B = Array(Array("A5", "B5", "C5"), Array("A6", "B6", "C6"))

  22.     '  UBound(A) = 3, UBound(A(0)) = 2
  23.     [A1].Resize(UBound(A) + 1, UBound(A(0)) + 1) = Application.Transpose(Application.Transpose(A))                       ' °}¦CA¼g¤J¤u§@ªí
  24.     '  UBound(A) = 3, UBound(B) = 1, UBound(B(0)) = 2
  25.     [A1].Offset(UBound(A) + 1).Resize(UBound(B) + 1, UBound(B(0)) + 1) = Application.Transpose(Application.Transpose(B)) ' °}¦CB¼g¤J¤u§@ªí

  26.     D = Range("A1").CurrentRegion.Value                                                                   ' ±NÀx¦s®æ¸ê®Æ¦s¦¨·s°}¦C
  27.     Range("A1").CurrentRegion = ""
  28.     '  UBound(D, 1) = 6,  UBound(D, 2) = 3
  29.     [A1].Resize(UBound(D, 1), UBound(D, 2)) = D                                                           ' ¼g¦^¤u§@ªí
  30. End Sub
½Æ»s¥N½X

TOP

¦^´_ 8# Hsieh

·PÁ¶Wª©
ss

TOP

        ÀR«ä¦Û¦b : ¤£­n¤p¬Ý¦Û¤v¡A¦]¬°¤H¦³µL­­ªº¥i¯à¡C
ªð¦^¦Cªí ¤W¤@¥DÃD