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

[µo°Ý] ±Æ°£Àx¦s®æ¤ºªº­«½Æ¸ê®Æ

[µo°Ý] ±Æ°£Àx¦s®æ¤ºªº­«½Æ¸ê®Æ



¦p¤Wªí,§Æ±æ±N"­ì¸ê®Æ"Ä椺,§â«á­±¦³­«½Æ¦r¦êªº³¡¤À²¾°£
²£¥X"±Æ°£­«½Æ" ªºµ²ªG
¨Ã­pºâ­ì¸ê®Æµ§¼Æ¤Î·s¸ê®Æµ§¼Æ

´M¨D¤j®aÀ°¦£,ÁÂÁÂ

±Æ°£­«½Æ.rar (1.54 KB)

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-10-22 20:05 ½s¿è

¦^´_ 1# ¤Ú§J´µ
  1. Sub Test()
  2.   Dim ar, d, i As Long, s
  3.   
  4.   Set d = CreateObject("scripting.dictionary")
  5.   With Sheets(1)
  6.   With .Range(.[A2], .[A2].End(xlDown)).Resize(, 2)
  7.     ar = .Value
  8.     For i = 1 To UBound(ar)
  9.         d.RemoveAll
  10.         For Each s In Split(ar(i, 1), ",")
  11.           d(s) = ""
  12.         Next
  13.         ar(i, 1) = Join(d.keys, ",")
  14.         ar(i, 2) = d.Count
  15.     Next
  16.     .Offset(, 2).Value = ar
  17.   End With
  18.   End With
  19. End Sub
½Æ»s¥N½X

TOP

ÁÂÁÂ,¥i¸Ñ¨M
¥i¬O¬Ý¤£¤ÓÀ´µ{¦¡¤º®e
¥i§_³Â·Ð¤j·§»¡©ú

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2013-10-23 14:39 ½s¿è

¦^´_ 3# ¤Ú§J´µ
¦r¨åª«¥ó»¡©ú¥i°Ñ¦Ò http://forum.twbts.com/thread-20-1-1.html
¨ä¾l¨ç¦¡½Ð¬d¾\»¡©ú¡C

¥D­n¬yµ{¬°¡G
¹ïÀx¦s®æ¤å¦r¥H³r¸¹¤À¸Ñ¦¨°}¦C (Split¨ç¦¡)¡A
µM«á¦s¤J¦r¨å®É¶¶«K§Q¥Î¦r¨åª«¥ó  Áä­È¥²©w°ß¤@  ¨Ó¶i¦æ¿z¿ï (d(s) = "")¡A
¨ú¦^¿z¿ï¹Lªº©Ò¦³­È (d.keys)¡A¦A¥Î³r¸¹¦X¦¨³æ¤@¦r¦ê (Join¨ç¦¡)¡AµM«á¼g¦^Àx¦s®æ¡C
  1. Sub Test()
  2.   Dim ar, d, i As Long, s
  3.   
  4.   Set d = CreateObject("scripting.dictionary")  '«Ø¥ß¦r¨åª«¥ó
  5.   With Sheets(1)
  6.   With .Range(.[A2], .[A2].End(xlDown)).Resize(, 2)  '¬Û·í©ó[A2:B8]
  7.     ar = .Value  '¤@¦¸©Ê±qexcel¨ú¥X
  8.     For i = 1 To UBound(ar)
  9.         d.RemoveAll  '²¾°£©Ò¦³­È
  10.         For Each s In Split(ar(i, 1), ",")  '¥H³r¸¹¤À¸Ñ¬°°}¦C
  11.           d(s) = ""
  12.         Next
  13.         ar(i, 1) = Join(d.keys, ",")  'µ²¦X°}¦C¬°³æ¤@¦r¦ê
  14.         ar(i, 2) = d.Count '¤¸¯À­Ó¼Æ
  15.     Next
  16.     .Offset(, 2).Value = ar  '¤@¦¸©Ê¼g¦^excel
  17.   End With
  18.   End With
  19. End Sub
½Æ»s¥N½X

TOP

¦^´_ 1# ¤Ú§J´µ
  1. InStr ¨ç¼Æ
  2. ¶Ç¦^¦b¬Y¦r¦ê¤¤¤@¦r¦êªº³Ì¥ý¥X²{¦ì¸m¡A¦¹¦ì¸m¬° Variant (Long)¡C
½Æ»s¥N½X
  1. Option Explicit
  2. Sub Ex()
  3.     Dim i As Integer, e As Variant, Ar As String
  4.     i = 2
  5.     Do While Cells(i, "a") <> ""
  6.         Ar = ","
  7.         For Each e In Split(Cells(i, "a"), ",")
  8.             If InStr(Ar, "," & e & ",") = 0 Then Ar = Ar & e & ","
  9.         Next
  10.         Cells(i, "C") = Mid(Ar, 2, Len(Ar) - 2)
  11.         Cells(i, "D") = UBound(Split(Mid(Ar, 2), ","))
  12.         i = i + 1
  13.     Loop
  14. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

ÁÂÁÂstillfish00 ¤Î GBKEE
¨â¦ì²¼äªºµ{¦¡¤Î¸Ñ»¡,¤S¾Ç¤F·sªº·Qªk¸ò°µªk

¤£¹L¹ïdictionary¤ñ¸û­¯¥Í
stillfish00 ªº¸Ñ»¡¤j­P¤F¸Ñ,¦ý¬O³¡¥÷»¡©úÁÙ¬O¤£À´

µM«á¦s¤J¦r¨å®É¶¶«K§Q¥Î¦r¨åª«¥ó  Áä­È¥²©w°ß¤@  ¨Ó¶i¦æ¿z¿ï (d(s) = "")
d(s)="" ¨Ó¶i¦æ¿z¿ï¥i¥H¦A¸ÑÄÀ²Ó³¡ªº³]©w·N¸q¶Ü?

·PÁÂ

TOP

¦^´_ 6# ¤Ú§J´µ
¦r¨å¦p¦P°}¦C©ÎCollection¡A¥i¥H·Q¦¨¬O¦s©ñ¦hµ§¸ê®Æªº®e¾¹¡A
¨ä¦s©ñªº¨C¤@µ§¸ê®Æ³£·|¥]§t¨â³¡¤À¡G¯Á¤Þ­È(©ÎºÙÁä­È¡BKey)©M¸ê®Æ¤º®e
¹³°}¦C¤@¼Ë¡A¯Á¤Þ­È¥²¶·°ß¤@
¦ý©M°}¦C¤ñ¸û°_¨Ó¡A¨Ï¥Î¦r¨åªº¦n³B«Ü¦h¡A¦p¡G
        ¯Á¤Þ­È¤£¥²¬°¼Æ¦r¡A¥i¥H¬O¦³·N¸qªº¦WºÙ¡C
        ®e©öÀH®É·s¼W©M²¾°£¡A¤£¥²¨Æ¥ý«Å§i°}¦C¤j¤p¡C
        ¦³Exists¤èªk®e©ö¬d§ä¬O§_¥]§t¦³¬Y­Ó¤¸¯À¡A¤£¥²¨Ï¥Î°j°é³v¤@Àˬd¡C

«e­±¥Îªº d(s) ·N«ä´N¬O¨ú±o¦r¨åd¤¤¡A¹ïÀ³¨ìsªº¨ºµ§¸ê®Æªº¤º®e¡C
d(s) = "" ´N¬O­×§ï¹ïÀ³¨ìsªº¸Óµ§¸ê®Æªº¤º®e¬°""

¤S¦]¬°¦r¨åªº¤@­Ó¯S©Ê¡G
·í¹ï¦r¨å¥Î¯Á¤Þ¨ú¦^®É¡A­Y¦r¨å¤£¥]§t¸Ó¯Á¤Þ­È®É·|¦Û°Ê¥[¤J¸Ó¯Á¤Þ­È¨ì¦r¨å¤º
©Ò¥H¥Î d(s) = "" ­×§ï¤º®e®É¡A¤]·|§â¦r¨å¤¤¤£¦s¦bªºs¥[¤J¡C

©ÎªÌ¡A§A¤]¥i¥H¥Î³o¼Ëªº¤èªk¼g¡G
  1.   For Each s In Split(ar(i, 1), ",")
  2.     If Not d.exists(s) Then
  3.       d.Add s, ""
  4.     End If
  5.   Next
½Æ»s¥N½X

TOP

·PÁÂ stillfish00 ¸Ô²Ó»¡©ú
ÂǦ¹¥i¥H§ó¤F¸Ñdictionary¤Î¾Ç²ßÀ³¥Î

TOP

¦^´_ 7# stillfish00
¦P¼Ë·PÁ stillfish00 ¹ï¦r¨åªº¸Ô²Ó»¡©ú,
¤@­Ó¹ï ¦r¨å «Ü­¯¥Íªº§Ú, ¯uªº«Ü·PÁÂ

TOP

ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,¦b¦P¤@°}¦C¸Ì±N·s­ÈÂл\­È,¤§«á¼g¤J¥Ø¼Ð®æ,
¾Ç²ß¤è®×¦p¤U,½Ð¦U¦ì«e½ú«ü±Ð

°õ¦æ«e:


°õ¦æµ²ªG:



Option Explicit
Sub TEST_2()
Dim Brr, Y, Z, i&, j&, T$, xR As Range
Set Y = CreateObject("Scripting.Dictionary")
Set xR = Range([B1], Cells(Rows.Count, 1).End(3)): Brr = xR
For i = 2 To UBound(Brr)
   If i = 2 Then Brr(1, 1) = "±Æ°£­«½Æ": Brr(1, 2) = "·sµ§¼Æ"
   Z = Split(Brr(i, 1), ",")
   For j = 0 To UBound(Z)
      If Y(i & "|" & Z(j)) = "" Then
         T = Y(i)
         If T = "" Then T = Z(j) Else: T = T & "," & Z(j)
         Brr(i, 1) = T: Y(i) = T: Y(i & "|" & Z(j)) = 1
         Y(i & "|c") = Y(i & "|c") + 1: Brr(i, 2) = Y(i & "|c")
      End If
   Next
Next
With xR.Offset(0, 2)
   .EntireColumn.ClearContents
   .Value = Brr
End With
Set Y = Nothing: Set xR = Nothing: Erase Brr, Z
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : °µ¦n¨Æ¤£¯à¤Ö§Ú¤@¤H¡A°µÃa¨Æ¤£¯à¦h§Ú¤@¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD