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

[µo°Ý] ¸ê®Æ¾ã²z

¬Ý¤F¥b¤Ñ¡A­Y¥Ñ§Ú¿ï¾Ü¡A§ÚÁÙ¬O·|¥Î¼Ï¯Ã
¼Ï¯Ã§¹¦¨«á¡A½Æ»s¼Ï¯Ã¤ÀªRªí¡A¿ï¾Ü©Ê¶K¤W­È¨ì¥t¤@­Ó°Ï¶ô
«áÄòªº§@·~´N¥i¥H¦b³o­Ó°Ï¶ô¥ô·N¦s¨ú¤£¨ü¼vÅT¤F¡C

TOP

¦]¬°³o­Ó¤½¦¡¤w¸g¼g®t¤£¦h¤F~©Ò¥H·Q»¡¥H³oºØ¤è¦¡§¹¦¨
³Â·Ð¤F~~
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦]¬°¦³¼g¥¨¶°~¥Î¼Ï¯Ãªº¸Ü¦³¿ìªk¦Û°Ê¶]¶Ü??
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¤£·Q¥Î¼Ï¯Ã¡A¥Î¥¨¶°¤]¥i¥H°Ú
¸ê®Æ¤j®É¥Î¤½¦¡¥²©w¦Y­WÀYªº
  1. a.gif
½Æ»s¥N½X

TOP

½Ð°Ý¸Ó¦p¦ó¼g¥¨¶°©O?

§ÚÂI¿ï½Æ»s¥N½X¶K¤W«á±o¨ì¥H¤Uµª®×

¤U¸ü (37.34 KB)
2 ¤p®É«e
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

½Ð°Ý¸Ó¦p¦ó¼g¥¨¶°©O?

§ÚÂI¿ï½Æ»s¥N½X¶K¤W«á±o¨ì¥H¤Uµª®×

¤U¸ü (37.34 KB)
2 ¤p®É«e
dragonbx µoªí©ó 2011-5-6 17:25
  1. Private Sub CommandButton1_Click()
  2.     Dim d As Object, d2 As Object, a, arr, i&, m&, r&
  3.     Set d = CreateObject("scripting.dictionary")
  4.     Set d2 = CreateObject("scripting.dictionary")
  5.     a = Range([a2], [b65536].End(3))
  6.     ReDim arr(1 To UBound(a), 1 To 250)
  7.     For i = 1 To UBound(a)
  8.         If d(a(i, 1)) = "" Then
  9.             m = m + 1
  10.             d(a(i, 1)) = m
  11.             d2(a(i, 1)) = 2
  12.             arr(1, d(a(i, 1))) = a(i, 1): arr(2, d(a(i, 1))) = a(i, 2)
  13.         Else
  14.             d2(a(i, 1)) = d2(a(i, 1)) + 1
  15.             arr(d2(a(i, 1)), d(a(i, 1))) = a(i, 2)
  16.             r = IIf(r > d2(a(i, 1)), r, d2(a(i, 1)))
  17.         End If
  18.     Next
  19.     [e:iv] = ""
  20.     [f1].Resize(r, m) = arr
  21.     ReDim arr(1 To r, 0)
  22.     For i = 1 To r - 1
  23.         arr(i, 0) = [b1] & i
  24.     Next
  25.     [e2].Resize(r - 1, 1) = arr
  26. End Sub
½Æ»s¥N½X

TOP

¥i¥H¤F~~·PÁ¤j¤jªº±Ð¾Ç
80 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¯uªº¬O¨ü±Ð³\¦h¡A¥Ñ©ó«Ü¦hExcel¤W­±ªº¥\¯à©Î¨ç¼Æ«Ü¤Ö¥h¨Ï¥Î¥¦¡A°£«D¦b¤u§@¤W¸g±`·|»Ý¨D¦hºØ¤£¦Pªº¥\¯à®É¤~·|·Q¿ìªk¥h¸Ñ¨M¡A¯uªº¬O©Ò¿×ªº"®Ñ¨ì¥Î®É¤è«ë¤Ö"¡C

TOP

¦^´_ 1# dragonbx


    ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹¥DÃD½m²ß°}¦C»P¦r¨å,½Ð¦U¦ì«e½ú¦A«ü¾É

20230315_2.zip (12.35 KB)

°õ¦æ«e:


°õ¦æµ²ªG:


Option Explicit
Sub Test()
Dim Brr, Crr, Y, i&, R&, M&, T2%, C%, T1$
'¡ô«Å§iÅܼÆ:(Brr,Crr,Y)¬O³q¥Î«¬ÅܼÆ,(i,R,M)¬Oªø¾ã¼ÆÅܼÆ,
'(T2,C)¬Oµu¾ã¼ÆÅܼÆ,T1¬O¦r¦êÅܼÆ

Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY³o³q¥Î«¬ÅܼƬO ¦r¨å
Set Brr = Sheets(1).UsedRange: Brr.Offset(0, 4).ClearContents
'¡ô¥OBrr³o³q¥Î«¬ÅܼƬO¯Á¤Þ¸¹1¤u§@ªí¦³¨Ï¥ÎªºÀx¦s®æ,
'¥OBrrÅܼƦV¥k°¾²¾4Ä檺Àx¦s®æ¤º®e²M°£

Brr = Brr: For i = 2 To UBound(Brr): Y(Val(Brr(i, 1))) = "": Next
'¡ô¥OBrr¬O¤Gºû°}¦C,¥HBrrÅܼƭȱa¤J
'³]¶¶°j°é!i±q2¨ì Brr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
'¥Oi°j°é¦C²Ä1ÄæBrr°}¦C­È¸gÂà¤Æ¬°¼Æ­È·íkey,item¬OªÅ¦r¤¸,¯Ç¤JY¦r¨å

ReDim Crr(1 To UBound(Brr), 1 To Y.Count + 1): Y.RemoveAll
'¡ô«Å§iCrr¬O¤Gºû°}¦C,Áa¦V½d³ò(1¨ìBrr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹)¦C,
'¾î¦V½d³ò(1¨ìY¦r¨åkey¼Æ¶q+1)Äæ
'²MªÅY¦r¨å

For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é!i±q2¨ì Brr°}¦CÁa¦V³Ì¤j¯Á¤Þ¸¹
   T1 = Val(Brr(i, 1)): T2 = Brr(i, 2)
   '¡ô¥OT1³o¦r¦êÅܼƬO i°j°é¦C²Ä1ÄæBrr°}¦C­È¸gÂà¤Æ¬°¼Æ­Èªº·s¦r¦ê
   If Not Y.Exists(T1 & "/C") Then
   '¡ô¦pªGT1ÅܼƳs±µ"/C"¦¨ªº¦r¦ê¦bY¦r¨å¸Ì¨S¦³¦¹key?
      C = C + 1: Y(T1 & "/C") = C: Crr(1, C + 1) = T1
      '¡ô¥OC³oµu¾ã¼ÆÅܼƲ֥[1
      '¥OT1ÅܼƳs±µ"/C"¦¨ªº¦r¦ê·íkey,item¬O CÅܼÆ,¯Ç¤JY¦r¨å¸Ì
      '¥O1¦C²Ä(CÅܼÆ+1)ÄæCrr°}¦C­È¬O T1ÅܼÆ

   End If
   R = Y(T1 & "/R"): R = R + 1: Y(T1 & "/R") = R
   '¡ô¥OR³oªø¾ã¼ÆÅܼƬO (T1ÅܼƳs±µ"/R"¦¨ªº¦r¦ê¬dY¦r¨å¦^¶Çitem­È):
   '¥ORÅܼƲ֥[1:¥OT1ÅܼƳs±µ"/R"¦¨ªº¦r¦ê·íkey,item¬ORÅܼÆ,©ñ¦^Y¦r¨å

   If R > M Then M = R: Crr(M + 1, 1) = Brr(1, 2) & M
   '¡ô¦pªGRÅܼƤj©ó ³oMªø¾ã¼ÆÅܼÆ!´N¥OMÅܼƬORÅܼƭÈ:
   '¥O(MÅܼÆ+1)¦C²Ä1ÄæCrr°}¦C­È¬O 1¦C²Ä2ÄæBrr°}¦C­È³s±µMÅܼƪº·s¦r¦ê

   Crr(Y(T1 & "/R") + 1, Y(T1 & "/C") + 1) = T2
   '¡ô¥O(Y(T1 & "/R") + 1)¦C²Ä(Y(T1 & "/C") + 1)ÄæCrr°}¦C­È¬O T2ÅܼÆ
   '(Y(T1 & "/R") + 1)¦C: T1ÅܼƳs±µ"/R"¦¨ªº¦r¦ê¬dY¦r¨åªºitem­È+1 ¦C
   '(Y(T1 & "/C") + 1)¦C: T1ÅܼƳs±µ"/C"¦¨ªº¦r¦ê¬dY¦r¨åªºitem­È+1 Äæ

Next
Crr(1, 1) = Brr(1, 1)
'¡ô¥O1¦C²Ä1ÄæCrr°}¦C­È¬O 1¦C²Ä1ÄæBrr°}¦C­È
[E1].Resize(M + 1, C + 1) = Crr
'¡ô¥O[E1]ÂX®i¦V¤U(MÅܼÆ+1)¦C,¦V¥kÂX®i(CÅܼÆ+1)Äæ,
'³oÂX®i½d³òÀx¦s®æ­È¥HCrr°}¦C­È±a¤J

Set Y = Nothing: Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : ¤â¤ß¦V¤U¬O§U¤H¡A¤â¤ß¦V¤W¬O¨D¤H¡F§U¤H§Ö¼Ö¡A¨D¤Hµh­W¡C
ªð¦^¦Cªí ¤W¤@¥DÃD