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

[µo°Ý] ·Q½Ð±ÐVBA°ª¤â¨âSHEETS¤ñ¸û«á§ä¥X¯S©w¤§Àx¦s®æ¦A¶K¤J¯S©w¦ì¸m¤¤

¦^´_ 1# YUPOYU
¤£¬O«ÜÀ´§Aªº·N«ä¡A¥ý¸Õ¸Õ¬Ý
  1. Sub ex()
  2. Set d = CreateObject("Scripting.Dictionary")
  3. With Sheet1
  4. For j = 2 To .[IV1].End(xlToLeft).Column
  5.     For i = 1 To .[A65536].End(xlUp).Row
  6.       If d(.Cells(i, j).Value) = "" Then
  7.       d(.Cells(i, j).Value) = .Cells(i, 1)
  8.       Else
  9.       d(.Cells(i, j).Value) = d(.Cells(i, j).Value) & "," & .Cells(i, 1)
  10.       End If
  11.     Next
  12. Next
  13. End With
  14. With Sheet2
  15.   For Each a In .Range(.[A1], .[IV1].End(xlToLeft))
  16.   If d(a.Value) <> "" Then
  17.     ar = Split(d(a.Value), ",")
  18.     With a.Offset(1).Resize(UBound(ar) + 1, 1)
  19.     .Value = Application.Transpose(ar)
  20.     .Sort key1:=.Cells(1), Header:=xlYes
  21.     End With
  22.   End If
  23.   Next
  24. End With
  25. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 3# YUPOYU
  1. Sub ex()
  2. Set d = CreateObject("Scripting.Dictionary")
  3. With Sheet1
  4. For j = 2 To .[IV1].End(xlToLeft).Column
  5.     For i = 1 To .[A65536].End(xlUp).Row
  6.       If d(.Cells(i, j).Value) = "" Then
  7.       d(.Cells(i, j).Value) = .Cells(i, 1)
  8.       Else
  9.       d(.Cells(i, j).Value) = d(.Cells(i, j).Value) & "," & .Cells(i, 1)
  10.       End If
  11.     Next
  12. Next
  13. ay = Split(Join(d.items, ","), ",")
  14. End With
  15. With Sheet2
  16.   For Each a In .Range(.[A1], .[IV1].End(xlToLeft))
  17.   If d(a.Value) <> "" Then
  18.      If mystr = "" Then
  19.       mystr = d(a.Value)
  20.       Else
  21.       mystr = mystr & "," & d(a.Value)
  22.       End If
  23.   End If
  24.   Next
  25.     ar = Split(mystr, ",")
  26.     .[A2].Resize(UBound(ar) + 1, 1) = Application.Transpose(ar)
  27. End With
  28. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 8# YUPOYU
¤£¬O¼Ò²Õ¦ì¸mªºÃö«Y¡A¬O§AªºÄæ¦ì°_©l¦ì¸m¤£¦P
  1. Sub ex()
  2. Set d = CreateObject("Scripting.Dictionary")
  3. With Sheet1
  4. For j = 8 To .[IV5].End(xlToLeft).Column
  5.     For i = 5 To .[G65536].End(xlUp).Row
  6.       If d(.Cells(i, j).Value) = "" Then
  7.       d(.Cells(i, j).Value) = .Cells(i, 7)
  8.       Else
  9.       d(.Cells(i, j).Value) = d(.Cells(i, j).Value) & "," & .Cells(i, 7)
  10.       End If
  11.     Next
  12. Next
  13. ay = Split(Join(d.items, ","), ",")
  14. End With
  15. With Sheet2
  16.   For Each a In .Range(.[A2], .[IV2].End(xlToLeft))
  17.   If d(a.Value) <> "" Then
  18.      If mystr = "" Then
  19.       mystr = d(a.Value)
  20.       Else
  21.       mystr = mystr & "," & d(a.Value)
  22.       End If
  23.   End If
  24.   Next
  25.     ar = Split(mystr, ",")
  26.     .[A3].Resize(UBound(ar) + 1, 1) = Application.Transpose(ar)
  27. End With
  28. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¤Ñ¤W³Ì¬ü¬O¬P¬P¡A¤H¥Í³Ì¬ü¬O·Å±¡¡C
ªð¦^¦Cªí ¤W¤@¥DÃD