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

[µo°Ý] ¸ê®Æ³B²z-§ä¥X°ß¤@ªº¸ê®Æ

[µo°Ý] ¸ê®Æ³B²z-§ä¥X°ß¤@ªº¸ê®Æ

¥»©«³Ì«á¥Ñ hugh0620 ©ó 2012-3-26 10:35 ½s¿è

Dear ¤j¤j­Ì
          ¤p§Ì¸g±`»Ý­n¹ï­«ÂЦhµ§¼Æ¾Ú±N¨ä¿@ÁY¦¨°ß¤@ªº¸ê®Æ~
          ¦b³o­Ó³B²z¤W,°ò¥»ªº§@ªk³£¬O±Ä¥Î[¶i¶¥¿z¿ï]ªº¤è¦¡,¥ý±N¸ê®Æ³B²z¦¨°ß¤@«á,
          ¦A¶i¦æ«áÄò¥[¤u¦¨¬°»Ý­nªºµ²ªG~
          ³Ì¦h³B²zªº¬O¨âÄ檺¸ê®Æ,¦pªþÀɤΤU¹Ï
          ¨Ìdata A¬°¥D,±N²Å¦Xdata Aªºdata B¸ê®Æ§ä¥X¨Ó~
          ¹³³o¼Ëªº¸ê®Æ,§Úªº³B²z¤è¦¡¤j·§¦p¤U
          1. [¶i¶¥¿z¿ï]ABÄæ¦ì,¿ï¾Ü¤£­«ÂÐ
          2. [¶i¶¥¿z¿ï]ªºµ²ªG,¦A¥Î°j°é+IF§PÂ_±o¨ì³Ì«áªºµ²ªG
          ©ß¥X³o­Ó°ÝÃD,½Ð¤j¤j¦³±Ð©ó§Ú

¸ê®Æ³B²z.rar (10.72 KB)
¾Ç²ß¤~¯à´£¤É¦Û¤v

ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð

°õ¦æ«e:


°õ¦æµ²ªG:


Option Explicit
Sub TEST()
Dim Brr, Y, i&, T1$, T2$, xR As Range
Set Y = CreateObject("Scripting.Dictionary")
Set xR = Range([B1], Cells(Rows.Count, "A").End(xlUp)): Brr = xR
For i = 1 To UBound(Brr)
   T1 = Brr(i, 1): T2 = Brr(i, 2)
   If Y(T1) = "" Then
      Y(T1) = Y.Count: Brr(Y(T1), 1) = T1: Brr(Y(T1), 2) = T2
      ElseIf InStr(Brr(Y(T1), 2), T2) = 0 Then
         Brr(Y(T1), 2) = Brr(Y(T1), 2) & "/" & T2
   End If
Next
xR.Offset(0, 9).ClearContents: xR.Offset(0, 9).Resize(Y.Count, 2) = Brr
Set Y = Nothing: Set xR = Nothing: Erase Brr
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 9# hugh0620
¥iªþ¤WÀɮ׬ݬÝ

TOP

¦^´_ 9# hugh0620


    ¦h¶µ¥Ø¤ñ¹ï¡A§Aªº·N«ä¬O»¡¦hÄæ¦ì¬Û¦P¬°¤@­Ó¶µ¥Ø¶Ü?
³o¼Ë¥i¥H§â¦hÄæ¦ì¦r¦ê³s±µ«á·í¦¨ÃöÁä¦r¡A´N¯à¹F¨ì¦hÄæ¦ì¤ñ¹ï
¦Ü©óÀÀ±Nkeys»Pitems¥t¥~¥H°}¦CÅܼÆÂà´«¡A§Ú¤£¥H¬°µM¡A¦]¬°keys»Pitems­ì¥»´N¬O¨â­Ó°}¦C
¥u¬O¦WºÙ¤£¦P½}¤F¡A¥Îªk¬O§_¤ñ¸û¦³¼u©Ê¡AÀ³¸Ó¤]¬Oµø±¡ªp¦Ó©w
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 6# GBKEE

   G¤j¤j~ ¤]»Ý­n½Ð±z¦A«ü±Ð¤@µf~

   ¤p§Ì¥ç°w¹ï¦b¤ñ¹ï¤W¦A´£¥X¤@¨Ç°ÝÃD,½Ð¤j¤j­Ì¦A¦³±Ð©ó§Ú
   Dictionary ¦b³B²zªº¬O¤Gºûªº¤ñ¹ï~ ¥ç¬J¬O¨â¨â¤ñ¸û~
   ­Y¬O·Q­n¤ñ¹ï3~N­Ó¶µ¥Øªº¸Ü~ ¤j¤j¬O§_¦³¨ä¥L§ó¦nªº³B²z¤è¦¡~
   ¥i¥H±Ð¾É¤@¤U
¾Ç²ß¤~¯à´£¤É¦Û¤v

TOP

¦^´_ 4# Hsieh

   Hsieh ¤j¤j~ «ÜÁÂÁ§Aªº«ü¾É~
   ¥J²Óªº¥h¤F¸ÑDictionaryªº»¡©ú»P±zªºµ{¦¡½X~
   ¦bÀ³¥Î¤W¨ü¯q¨}¦h~  ¦b¨â­Ó¤ñ¹ï¤WªºÀ³¥Î¤£¥Î¹³¥H«e­n¦h¦¸¿z¿ï«á~ ¤~¯à§¹¦¨~

   ¤p§Ì¥ç°w¹ï¦b¤ñ¹ï¤W¦A´£¥X¤@¨Ç°ÝÃD,½Ð¤j¤j­Ì¦A¦³±Ð©ó§Ú
   Dictionary ¦b³B²zªº¬O¤Gºûªº¤ñ¹ï~ ¥ç¬J¬O¨â¨â¤ñ¸û~
   ­Y¬O·Q­n¤ñ¹ï3~N­Ó¶µ¥Øªº¸Ü~ ¤j¤j¬O§_¦³¨ä¥L§ó¦nªº³B²z¤è¦¡~
   ¥i¥H±Ð¾É¤@¤U
  1. a = d.keys
  2. b = d.items
  3. For i = 0 To d.Count - 1
  4.     Range("J" & 1 + i) = a(i)
  5.     Range("K" & 1 + i) = b(i)
  6. Next
  7. '³z¹LDictionaryªº½d¨Ò»¡©ú~ ¥Î¥t¥~¤@ºØ¤ñ¸ûª½Ä±ªºªí¹F¤è¦¡
  8. '»P±z¼gªº¤U­±¨â¦æ¥i¥H¹F¨ì¤@¼Ëªº¥\¯à~
  9. '¤j¤j¼gªº¬O¶i¶¥ªº¥Îªk~ ¤p§Ì³ßÅw©î¦¨¦Û¤v¤ñ¸ûª½Ä±ªº¥Îªk~
  10. '¤£µMµw¬O¥h®M¥Î~ ´N¤ñ¸û¨S¦³¼u©Ê
  11. '[J1].Resize(d.Count, 1) = Application.Transpose(d.keys)
  12. '[K1].Resize(d.Count, 1) = Application.Transpose(d.items)
½Æ»s¥N½X
¾Ç²ß¤~¯à´£¤É¦Û¤v

TOP

¦^´_ 6# GBKEE


    ÁÂÁÂG¤j¤j~ ±Ð¾É~ ¤p§Ì·|¦n¦n²z¸Ñªº~
¾Ç²ß¤~¯à´£¤É¦Û¤v

TOP

¦^´_ 3# hugh0620
'["Scripting.Dictionary"]<==³o¬O¤°»ò·N«ä©O??,'¦]¬°¤j¤j¦³¨Ç®É­Ô¥Îªº¤è¦¡¡A«öF1¬O¬d¤£¨ìªº
Dictionary ª«¥ó ->¦r¨åª«¥ó : ´N¹³¬d¦r¨å ,¬d¨ì¤@­ÓÃöÁä¦r(Key)«á¦³¬Û¹ïªº»¡©ú (Item)
Key  ¸ÓÃöÁä¦r¥Î¨Ó¨ú¥X³æ­Ó¶µ¥Ø¡A³q±`¬O¾ã¼Æ©Î¦r¦ê¡A¥i¥H¬O°£°}¦C¥~ªº¥ô¦ó«¬ºA¡C
Item  ¥i¥H¬O¥ô¦ó«¬ºAªº

¬d¬Ý Dictionary ª«¥ó ªº»¡©ú ¦p¹Ï

TOP

¦^´_ 4# Hsieh


    Hsieh ¤j¤j~ ³o­ÓªF¦è¤ñ¸û©â¶H¤@¨Ç~ ­nªáÂI®É¶¡¨Ó®ø¤Æ¤@¤U~
    ¤p§Ì¦A±N²z¸Ñªºµ²ªG~ ¤À¨É¤@¤U~ ¦A½Ð¤j¤j«ü¥¿¤@¤U~
¾Ç²ß¤~¯à´£¤É¦Û¤v

TOP

¦^´_ 3# hugh0620
»{ÃÑDictionary   
VBA»¡©úÀɽХÑFileSystemObject ª«¥ó»¡©ú¤¤ªº¡i½Ð°Ñ¾\¡j¤¤·j´M

Application.Transpose(d.keys)»PApplication.Transpose(d.items)³o¥u¬O±N¦r¨åª«¥óªº¯Á¤Þ°}¦C»P¤º®e°}¦CÂà¸m
¦r¨åª«¥ó¥i¥Î¤ñ¸û²³æªº·§©À¨Ó²z¸Ñ
ª«¥ó¤¤·|¦s¦b2­Ó°}¦Ckeys¡Aitems
keys¬OÀx¦sÃöÁä¦rªº°}¦C
items¬O¹ïÀ³ÃöÁä¦rªº¤º®e°}¦C
¨C¤@­Ókey·|¹ïÀ³¤@­Óitem
³o¨â­Ó°}¦C¦s¦b¬O¾î¦V±Æ¦C¡A©Ò¥H¡A·í­n¼g¤JÀx¦s®æ®É¡A¥²¶·Âন»PÀx¦s®æ¦P¦Vªº°}¦C
­Y¥Hª«¥óªºadd¤èªk¥[¤J¤¸¯À®É¡A¦pªGÃöÁä¦r(key)­«½Æ®É·|²£¥Í¿ù»~¡A¥²¶·¥ýÀˬd¬O§_¤w¸g¦s¦b¸Ó¶µ¥Ø(³o­Ó¯S©Ê¥Î¨Ó¨ú±o¤£­«½Æ²M³æ)
¨Ï¥Îdiction(key)=item³o¼Ëªº¤è¦¡¥[¤J¶µ¥Ø¡A·|¥H«á¨Óªºitem¨ú¥N­ì¥ý ªºitem
­Y¦³¥ô¦ó°ÝÃD¡AÅwªï´£¥X°Q½×¡A¤]½Ð¹ï¦¹ª«¥ó¼ô±xªºªB¤Í¥[¤J°Q½×
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¡i°µ¤Hªº¶}©l¡j¨C¤@¤Ñ³£¬O¬G¤Hªº¶}©l¡A¨C¤@­Ó®É¨è³£¬O¦Û¤vªºÄµ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD