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

[µo°Ý] ²M°£­«Âиê®Æ,¥u¦s¯d1µ§¸ê®Æ

¦^´_ 10# ­ã´£³¡ªL

¦P·N²a´£³¡ªL«e½ú©Ò¨¥,

¤]½Ð¤¹³\¤p§Ì«_¬N´£ÂI¬Ýªk,µo¨¥¦³¤£·í³B½Ð¤£§[«ü¥¿,¤p§Ì¤@©w§ï¶i.

¤p§Ì¥H¬°,
´£¨ÑªþÀɪº²z¥Ñ¤§¤@¦b©ó¸ÑµªªÌ¤£»Ý¦A¤â°Ê¦Û¤vÁä¤J¸ê®Æ¥h¶i¦æ´ú¸Õ,¬Ù¥h³Â·Ð.
ªO¤W«e½úÄ@·NµLÀv´£¨Ñ¸Ñµª,´£°ÝªºªO¤Í´£¨ÑªþÀÉ,À³¤£¬O¤Ó¤j§xÃø.

²z¥Ñ¤§¤G¦b©ó¦³®É¤£´£¨ÑªþÀÉ,¯uªº®e©ö³y¦¨»~·|,¦]¨C¤H·Q¨Æ±¡¬Ý¨Æ±¡ªº¨¤«×¤£¦P,
­Y¦³ªþÀÉ,¥i¯à·|§ó©ö²z¸Ñ°ÝÃD©Ò¦b.

¨ä¹ê«e­±¦^¤å¤w¦³¤£¤Ö°ª¤â«e½ú­Ì¦^Âк맮¸Ñµª,
¥¼¯àµª¨ìªO¤Í·Q­nªº®ÄªG,¥i¯à´N¬OµLªþÀɤ§¬G¾É­P²£¥Í¹ï°ÝÃDªº»~¸Ñ,
­Y¦³´£¨ÑªþÀÉ,·Q¥²¯à§K¥h¦¹¤@¿ò¾Ñ.

¥H¤W©Ò¨¥¶È¨Ñ°Ñ¦Ò,¤£·í³B½Ð®ü²[.

¤p§Ì¤æÁx,
ªþ¤W¤p§Ì­×§ï¦Û²a´£³¡ªL«e½ú©Ò¼g¤§µ{¦¡½X«áªºª©¥»¤ÎÀÉ®×,µ´«D¤p§Ì©Ò­ì³Ð,¯S¦¹Án©ú.

vba¥\¤O¤Ó®t,§ï±o¤£¦n,§Æ±æ¦³©ÒÀ°§U,¦³¤£·í³B¤]½Ð«e½ú­Ì°È¥²«üÂI¤@¤G,·PÁÂ.
¥»·Q¼gµù¸Ñ,¦ý¦]¥Ø«e¹ï«e½ú©Ò¼gªº­ì¥»µ{¦¡½XÁÙ¤£´±»¡¤w¦³¥R¤Àªº²z¸Ñ,
¦³®É¬Oª¾¨äµM¦Ó¤£ª¾¨ä©Ò¥HµM,¹ç¥i¥ý¤£¼g,¥H§K¦³»~¾ÉªO¤Í¤§¶û,½Ð¨£½Ì...
  1. '¦¹µ{¦¡½X­×§ï¦Û³Â»¶®a±Ú°Q½×°Ïexcel°ª¤â²a´£³¡ªL«e½ú©Ò¼g,«D§Ú¦Û³Ð.
  2. '°Q½×°Ïºô§}:http://forum.twbts.com/index.php

  3. Sub test()
  4. Dim arr, brr, myD, N, T
  5. Set myD = CreateObject("scripting.dictionary")
  6. arr = Range("a2:d" & Cells(Rows.Count, 1).End(xlUp).Row)
  7. ReDim brr(1 To UBound(arr), 1 To 4)
  8. N = 1
  9. For i = 1 To UBound(arr)
  10. T = arr(i, 2) & arr(i, 3) & arr(i, 4)
  11. If myD(T) = 1 Then GoTo 101
  12. For j = 1 To 4
  13. brr(N, j) = arr(i, j)
  14. Next j
  15. N = N + 1
  16. myD(T) = 1
  17. 101:
  18. Next i
  19. If N > 0 Then [h2].Resize(N, 4) = brr
  20. End Sub
½Æ»s¥N½X
2-2 (¦hÄæ¸ê®Æ)¦hÄæ¸ê®Æ¬Ò¬Û¦P¤~§R°£­«½Æ¾î¦C.zip (9.44 KB)

TOP

¦^´_ 11# greetingsfromtw
VBA ¦³³\¦h¼gªk¥i¹F¨ì¬Û¦Pªº®ÄªG
  1. Option Explicit
  2. Sub Ex()
  3.     Dim D As Object, AR(), i As Integer
  4.     Set D = CreateObject("scripting.dictionary")
  5.     AR = Range("a1:d" & Cells(Rows.Count, 1).End(xlUp).Row)
  6.     For i = 1 To UBound(AR)
  7.       If Not D.exists(AR(i, 2) & AR(i, 3) & AR(i, 4)) Then  '** exists  ¶Ç¦^¦r¨åª«¥ó¬O§_¦³³okey­È  ¦³ True :µL False
  8.         D(AR(i, 2) & AR(i, 3) & AR(i, 4)) = Application.Index(AR, i)  '** ¤u§@ªí¨ç¼Æ Index
  9.       End If
  10.     Next
  11.     With Range("H1")
  12.         .CurrentRegion.Clear
  13.         .Resize(D.Count, 4) = Application.Transpose(Application.Transpose(D.items))
  14.     End With
  15. End Sub
  16. Sub Ex1()
  17.     Dim D As Object, i As Integer
  18.     Set D = CreateObject("scripting.dictionary")
  19.     With Range("a1:d" & Cells(Rows.Count, 1).End(xlUp).Row)
  20.         For i = 1 To .Rows.Count
  21.             If Not D.exists(.Cells(i, 2) & Cells(i, 3) & .Cells(i, 4)) Then '** exists  ¶Ç¦^¦r¨åª«¥ó¬O§_¦³³okey­È  ¦³ True :µL False
  22.                 D(.Cells(i, 2) & Cells(i, 3) & .Cells(i, 4)) = .Rows(i)
  23.             End If
  24.         Next
  25.     End With
  26.     With Range("H1")
  27.         .CurrentRegion.Clear
  28.          .Resize(D.Count, 4) = Application.Transpose(Application.Transpose(D.items))
  29.     End With
  30. End Sub
  31. Sub Ex2()
  32.     Dim AR, ArSt(), i As Integer, St As String
  33.     With Range("a1:d" & Cells(Rows.Count, 1).End(xlUp).Row)
  34.         For i = 1 To .Rows.Count
  35.                 St = .Cells(i, 2) & Cells(i, 3) & .Cells(i, 4)
  36.                 If IsEmpty(AR) Then
  37.                     ReDim AR(1 To 1):     AR(1) = .Rows(i)
  38.                     ReDim ArSt(1 To 1):   ArSt(1) = St
  39.                 Else
  40.                     If UBound(Filter(ArSt, St)) = -1 Then
  41.                         'Filter ¨ç¼Æ¶Ç¦^¤@­Ó±q¹s¶}©lªº°}¦C¡A¸Ó°}¦C¥]§t°ò©ó«ü©w¿z¿ï·Ç«hªº¤@­Ó¦r¦ê°}¦Cªº¤l¶°¡C
  42.                         '»yªk  Filter(sourcesrray, match[, include[, compare]])
  43.                         '¦pªG¦b sourcearray ¤¤¨S¦³µo²{»P match ¬Û²Å¦Xªº­È¡AFilter ¶Ç¦^¤@­ÓµL°}¦C¡C¦pªG sourcearray ¬O Null ©Î¤£¬O¤@­Ó¤@ºû°}¦C¡A«h²£¥Í¿ù»~¡C
  44.                         'Filter ¨ç¼Æ©Ò¶Ç¦^ªº°}¦C¡A¨ä²Õ¦¨¶µ¥Ø¼Æ­è¦n¬O©Ò§ä¨ìªº²Å¦X¶µ¥Ø¼Æ¡C
  45.                         ReDim Preserve ArSt(1 To UBound(ArSt) + 1)
  46.                         ArSt(UBound(ArSt)) = St
  47.                         ReDim Preserve AR(1 To UBound(AR) + 1)
  48.                         AR(UBound(AR)) = .Rows(i)
  49.                     End If
  50.             End If
  51.         Next
  52.     End With
  53.     With Range("H1")
  54.         .CurrentRegion.Clear
  55.          .Resize(UBound(AR), 4) = Application.Transpose(Application.Transpose(AR))
  56.     End With
  57. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

Application.Transpose ¦b¤£¦Pª©¥»ªºoffice¦U¦³¨ä³Ì¤j­­¨î¦C¼Æ,
ÁöµM¤j®a´X¥G³£¥Î¤F·sª©¥», ¦ýÁÙ¬O­n´£¿ô¤@¤U¨ä¥L¤´¨Ï¥Î¸ûª©¥»ªº¨Ï¥ÎªÌ!

TOP

¦^´_ 12# GBKEE
¦^´_ 13# ­ã´£³¡ªL

«D±`·PÁÂGBKEE«e½ú´£¨Ñ¥t¤@ºØ¤è¦¡´£¨Ñ½×¾ÂªO¤Í¾Ç²ß,«D±`­È±o¬ã¨s,¤p§Ì©ê«ù·P®¦ªº¤ß¦¬¤U¤F.
¤]«D±`·PÁ²a´£³¡ªL«e½ú´£¿ô½×¾ÂªO¤ÍÃö©óApplication.Transposeªº­­¨î,¥H«á¤p§Ì½m²ß®É¤]·|¯S§Oª`·N³o­Ó³¡¥÷.

TOP

¦^´_ 12# GBKEE


   GBKEE«e½ú
ªþ¥ó¬O©Ò»Ý­nªº¤º®e»P§e²{ªº¦¨ªG
¤Ó±ß¦^ÂЪí¥Ü©êºp

¥t·PÁ¦h¦ì«e½úªº«ü±Ð§Ú¥¿¦b§V¤O®ø¤Æ¤¤
¶}¤ß¾Ç²ß,¾Ç²ß«Ü¶}¤ß

TOP

¦^´_ 10# ­ã´£³¡ªL


    ­ã´£³¡ªL «e½ú
°ÝÃD¸Ñ¨M¤F
§Úªº²¨¥¢³y¦¨§O¤Hªº§xÂZ,¤U¦^¦³°ÝÃD¤@©w¤W¶ÇªþÀÉ

¤]ÁÂÁ¦h¦ì«e½úªº«ü±Ð
¶}¤ß¾Ç²ß,¾Ç²ß«Ü¶}¤ß

TOP

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

°õ¦æ«e:


°õ¦æµ²ªG:



Option Explicit
Sub TEST_1()
Dim Brr, Y, i&, j&, N&, T$
'¡ô«Å§iÅܼÆ
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OYÅܼƬO ¦r¨å
Brr = Range([D1], Cells(Rows.Count, "A").End(xlUp))
'¡ô¥OBrrÅܼƬO ¤Gºû°}¦C,¥HÀx¦s®æ­È±a¤J°}¦C¸Ì
For i = 2 To UBound(Brr)
'¡ô³]¶¶°j°é
   For j = 2 To 4: T = T & Brr(i, j) & "|": Next
   '¡ô³]¤º¶¶°j°é!¦¬¶°¦r¦ê¥H"|"²Å¸¹¶¡¹j
   If Y(T) = "" Then
   '¡ô¦pªG¥HTÅܼƬdY¦r¨å±oitem¬O ªÅ¦r¤¸?
      N = N + 1: Y(T) = "@": T = ""
      '¡ô¥ONÅܼƲ֥[1(«ü©wµ²ªG¸ê®Æ¦C¸¹),
      '¥OTÅܼƷíkey,item¬O "@",¯Ç¤JY¦r¨å(³o¬O­nµù°Oitem¤£¬O "")
      '¥OTÅܼƬO ªÅ¦r¤¸(¦]¬°¤U­Ó°j°é°õ¦æ«e­n²MªÅ¦¹ÅܼÆ)

      For j = 1 To 4: Brr(N + 1, j) = Brr(i, j): Next
      '¡ô³]¤º¶¶°j°é!±N²Å¦X±ø¥óªº¸ê®Æ³v¦¸±a¤Jµ²ªG¦C
   End If
Next
[H:K].ClearContents
'¡ô¥O²M°£Âµ²ªG¸ê®Æ
[H1].Resize(N + 1, 4) = Brr
'¡ô¥OBrr°}¦C¸ê®Æ±q[H1]Àx¦s®æ¶}©l¼g¤J­È
'(N+1:¬O¦]¬°²Ä¤@¦C¬O¼ÐÃD¦C,¦ÓNªº²Ö­p¤£¥]§t¼ÐÃD¦C)
Set Y = Nothing: Erase Brr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

        ÀR«ä¦Û¦b : ¤Ó¶§¥ú¤j¡B¤÷¥À®¦¤j¡B§g¤l¶q¤j¡A¤p¤H®ð¤j¡C
ªð¦^¦Cªí ¤W¤@¥DÃD