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

[µo°Ý] ¦p¦ó¥[¸ê®Æ

§¹¥þ¬Ý¤£À´©pÅÞ¿è
½Ð±N¶·¨D±Ô­z²M·¡¡A¹ê¦bµLªk±q§A¿ù»~ªº¥N½X¡A§ä¥X§AªºÅÞ¿è
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

§Ú°µ¤F¤@­Ó§¹¾ãªºµ{¦¡,¼Ó¥D¥i¥H¸Õ¸Õ,¤j®a¤]¥iµ¹·N¨£
¼g±o¯uºC,40´X¦æªá¤F¤@¤Ñ®É¶¡
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 10# FAlonso
  1. Sub Ex()
  2. On Error Resume Next
  3. Dim Mystr(), MyCnt()
  4. i = 1
  5. Do Until Cells(i, 1) = ""
  6.    If IsError(Application.Match(Cells(i, 1) & "," & Cells(i, 2) & "," & Cells(i, 3) & "," & Cells(i, 4), Mystr, 0)) Then
  7.       ReDim Preserve Mystr(s)
  8.       ReDim Preserve MyCnt(s)
  9.       Mystr(s) = Cells(i, 1) & "," & Cells(i, 2) & "," & Cells(i, 3) & "," & Cells(i, 4)
  10.       MyCnt(s) = Cells(i, 5)
  11.       s = s + 1
  12.       Else
  13.       k = Application.Match(Cells(i, 1) & "," & Cells(i, 2) & "," & Cells(i, 3) & "," & Cells(i, 4), Mystr, 0)
  14.       MyCnt(k) = MyCnt(k - 1) + Cells(i, 5)
  15.     End If
  16.     i = i + 1
  17. Loop
  18. For i = 0 To s - 1
  19.    Cells(i + 1, 8).Resize(, 4) = Split(Mystr(i), ",")
  20.    Cells(i + 1, 12) = MyCnt(i)
  21. Next
  22. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

ÁÙ¦³1­Ó¤p°ÝÃD·Q½Ð±ÐHsieh¤j¤jªº.
¥i§_¥Î Range(cells(,),cells(,)) ¦P®ÉSelect  2­Óor¦h­Ó¦a¤è?
Range(cells(a,b),cells(c,d)) + Range(cells(e,f),cells(g,h))
50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦bVBE¼Ò¦¡¤U¦³¤@­Ó?¸¹,´N¬O¦b¼gVBA¦³°Ý¬OÃD®É¥i¥HÂI¤@¤U°Ý¸¹,µM«á§â¤£À´ªº¥´¶i¥h·j´M,³qªø³£·|±o¨ìµª®×.
¦p¤U´N¬O Scripting.Dictionary ·j´M¥X¨Óªºµ²ªG,


Dictionary ª«¥ó»P PERL ¬ÛÃö°}¦C¤@¼Ë¡C¥i¥H¦s©ñ¥ô¦ó«¬¦¡ªº¸ê®Æ¶µ¥Ø°}¦C¡C¨C­Ó¶µ¥Ø³£¬O°ß¤@ªºÃöÁä¦r¡C¸ÓÃöÁä¦r¥Î¨Ó¨ú¥X³æ­Ó¶µ¥Ø¡A³q±`¬O¾ã¼Æ©Î¦r¦ê¡A¥i¥H¬O¦s©ñ°£°}¦C¥H¥~ªº¥ô¦ó«¬§O¸ê®Æ¡C

¤U­±Á|¨Ò»¡©ú¤F¦p¦ó«Ø¥ß¤@­Ó Dictionary ª«¥ó¡G

Dim d                        '«Ø¥ß¤@­ÓÅܼÆ
Set d = CreateObject(Scripting.Dictionary)
d.Add "a", "Athens"     '¥[¤J¤@¨ÇÃöÁä¦r©M¶µ¥Ø
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
...

¦]¬°»¡©úÀɬOª½±µÂ½Ä¶ªº©Ò¥H¤å¥y«Ü¤£¶¶,¥H¤W¤å¦r¦³¸g¹L­×§ï,¦ý¬O¥Ø«e»¡©úÀɤ´µM¬O¾Ç²ßExcel³Ì²«Kªº¤u¨ã,¤j®a°µ°Ñ¦Ò.
V98

TOP

¦^´_ 15# linshin1999

Åܼƭn¥ÎObject¶Ü?
Dim d as Object ??
50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_  basarasy
³o¬O«Üª½Æ[ªº¥N½X
Hsieh µoªí©ó 2011-1-3 22:50


¨â¦¸¨Ï¥Îapplication.transpose¦³ÂIÃø¸Ñ,¼Æ¾Ç¤WÀ³¸Ó¨SÂàÅÜ,©Ò¿×ªº"¼Ð·Ç¤Gºû°}¦C"¬O¤°»ò
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¥»©«³Ì«á¥Ñ 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
  1. Sub abc()
  2. Dim mystring
  3. mystring = Join(Application.Transpose(Range("A1:a4").Value), ",")  'ª`·N³o¸Ì¬O¤@­Ócolumn¦ê

  4. Range("A10").Value = mystring

  5. End Sub
½Æ»s¥N½X
±N¤@­Órowªº¦r³s¦ê:
transpose¤G¦¸

  A    B    C    D
1  r   t    u    i
  1. Sub abc()
  2. Dim mystring
  3. mystring = Join(Application.Transpose(Application.Transpose(Range("A1:D1"))), ",") 'ª`·N³o¸Ì¬O¤@­Órow¦ê

  4. Range("A10").Value = mystring

  5. End Sub
½Æ»s¥N½X
µ²ªG¬Or,t,u,i

¤µ¤é°µ¤F¤@ÂI¸Ô²Ó¬ã¨s,¬O¤gªk¤jÁå¿û
¥ý§â¥H¤Uµ{¦¡§Û¶iVBA
  1. Sub check()
  2. Dim ar As Variant
  3. Dim i As Integer

  4. Set ar = [a1:a4]   'try [a1:d1] later

  5. For i = 1 To 6
  6. ar = Application.Transpose(ar)
  7. Next

  8. Set ar = Nothing

  9. 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¼ËÀ³¸Ó¯à°÷¸ÑÄÀ¬°¤°»òrow­ntranspose¦h¤@¦¸,¦ýrow¬°¤°»ò­n­º¥ýÅܦ¨column§Î,¤£­n°Ý§Ú

³Ì«ád1.items¨º¦æ
¬Ý¥H¤U¨Ò¤l
  1. Dim myrange As Range
  2. Dim i As Integer, k
  3. Set myobject = CreateObject("scripting.dictionary")

  4. myobject("A") = Array(1, 2)
  5. myobject("B") = Array(4, 5)
  6. myobject("C") = Array(7, 8)

  7. Set myrange = Worksheets("sheet2").Range("A1").Resize(3, 2)

  8. k = myobject.items
  9. k = Application.Transpose(Application.Transpose(k))
  10. 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
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 18# FAlonso
Àx¦s®æ«ü©w¥X¨Óªº½d³ò
¤£½×¬O1¦C©Î¦h¦C
excel§¡±Nµø¬°¤Gºû°}¦C
¸g¹Ltranspose¨ç¼ÆÂà¸m«á¤~·|±o¨ì¥¿½Tªººû¼Æ
©Ò¥H·í§Aªº­ì°}¦C¬O¥H¤@ºû°}¦CÀx¦s¦h­Ó°}¦C¦¨¬°¦hºû°}¦C®É
¦p
Dim Ay()
For i = 0 To 10
   ReDim Preserve Ay(i)
   Ay(i) = Array(i * 1, i * 2, i * 3, i * 4, i * 5)
Next
[A1].Resize(i, 5) = Application.Transpose(Application.Transpose(Ay))
Ay°}¦C¤¸¯À¬O°}¦C
­n¥H¤@¦¸¼g¤J´N¥²¶·¨Ï¥Î2¦¸transpose
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 19# Hsieh
¨º»ò¥¿½Tªººû¼Æ¨ä¹ê¬O«ç¼Ë©w¸q? ·Q¨Ó·Q¥h³£·Q¤£³q
¦b§Úªº¥Ü½d,Range("A1:A4")ºâ¤£ºâ¬O¤@­Ó°}¦C?
¬°¤°»ò¥´ª½ªº®æ¤l,¤@¦¸transpose´N¥i¥H,¥´¾îªº­n¨â¦¸? §Ú¸Õ¹L¥´ª½ªº¥Î¨â¦¸transpose,·|¦³¿ù»~¥X²{

ÁÙ¦³
  1. d(mystr) = d(mystr) + A.Offset(, 4).Value
½Æ»s¥N½X
³o¥y¬O«ç¸ÑÄÀ,¬°¤°»ò¥i¥H§@²Ö¥[ªº§@¥Î
¬O§_dictionary¦Û°Ê´N¬Oarray,¤£»Ýdeclare(§Y¹³´¶³qªºÅܼƭn§@x()³o¼Ëªº«Å§i))?

§Æ±æH¤j¸Ñµª
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

        ÀR«ä¦Û¦b : ­n§åµû§O¤H®É¡A¥ý·Q·Q¦Û¤v¬O§_§¹¬üµL¯Ê¡C
ªð¦^¦Cªí ¤W¤@¥DÃD