- ©«¤l
- 10
- ¥DÃD
- 2
- ºëµØ
- 0
- ¿n¤À
- 19
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- office 2007
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2010-5-29
- ³Ì«áµn¿ý
- 2011-10-12
|
- Sub matchdata()
- Dim Ay() '¥þ°ìÅܼÆAy¥Î¨Ó©ñ³Ì²×µ²ªG
- Set d = CreateObject("Scripting.Dictionary") '³Ð¥ß¤@Ó ¤Gºû°}¦Cªºª«¥ód
- With Sheet2
- For Each A In .Range(.[A2], .[A65536].End(xlUp)) '²Ä¤G±iªíªºAÄæ ³v¦C =¼È¦sÅܼÆA
- If d.exists(A.Value) = False Then '¥ÎDictionaryªºExists¨ç¼Æ ¨ÓÀˬd¤ñ¹ïAªºÈ¦pªG¨S¦³«h°õ¦æ¤U¤@¦æ
- d(A.Value) = Join(Array(A, A.Offset(, 1), A.Offset(, 2), A.Offset(, 3)), ",") '¨úÈ?? ¾î¦Vªº 1A,1B,1C Âæ
- Else '¦pªG¦³
- d(A.Value) = d(A.Value) & ";" & Join(Array(A, A.Offset(, 1), A.Offset(, 2), A.Offset(, 3)), ",") '¦êÁp°_¨Ó¥Î;¹j¶} Åܦ¨1A,1B,1C;2A,2B,2C ¨ú¥Xªº®ÉÔ·|Åܦ¨¨â¦C©Î§ó¦h¦Cªº¤TÄæ¸ê®Æ
- End If
- Next
- End With
- With Sheet1
- For Each A In .Range(.[C2], .[C65536].End(xlUp)) '²Ä¤@±iªíªºCÄæ ³v¦C =¼È¦sÅܼÆA
- If d.exists(A.Value) = True Then '¤Gºû°}¦Cdªºª«¥ó Y¦³¥]§t³o¦¸ªºÅܼÆa
- Ar = Split(d(A.Value), ";") '¨ú¥X¥i¥Îªº¼Æµ§¸ê®Æ ª½¦Vªº ¥i¥Îµ§¼Æ X ABC¤TÄæ
- For i = 0 To UBound(Ar) '0¨ì °}¦CArªº³Ì¤jÈ
- ReDim Preserve Ay(s) '«O¦s°ÊºA°}¦Cªº¤º®e (¬°¤°»òÀx¦s¼g¦b«e± ³B²z¤è¦¡¼g¦b¤U¤@¦æ?)
- Ay(s) = Split(A.Offset(, -2) & "," & A.Offset(, -1) & "," & Ar(i), ",")
- s = s + 1 '¥Ø«e¦C+1
- Next
- Else
- If mystr = "" Then mystr = A Else mystr = mystr & "," & A 'Yd.exists(A.Value) = false ¼g¤J¤@Óĵ§iÅã¥Ü¥Ø«eÅܼÆA
- End If
- Next
- End With
- With Sheet3
- .[A2:F65536] = "" '²MªÅ²Ä¤T±iªí
- .[A2].Resize(s, 6) = Application.Transpose(Application.Transpose(Ay)) '²Ä¤T±iªí ªºA2Äæ ¶}©l¼g¤JÂà´«¹Lªº¦æ¦C Âà´«¤F¨â¦¸ ¶W²`¶ø µLªk·Q¹³..
- MsgBox mystr & "¨S§ä¨ì" '¼u¥Xĵ§iµøµ¡
- End With
- End Sub
½Æ»s¥N½X Hsieh ¤j¤j ¥Ø«eÀ³¥Î¥¿½T¤F
³o¬O§Ú¥Ø«e¦Û¤v¼gªºª`¸Ñ ¤£ª¾¹D¬O¤£¬O¥¿½T..
¥t¥~·Q½Ð°Ý¤@¤U
¬°¤°»òn¥ýŪ¤J¥þ³¡ªºSheet2ªºÄæ¦ì¡AYSheet2¦³¦n´X¸Uµ§ªº®ÉÔ ¦³¨S¦³®Ä¯à°ÝÃD§r?
³B²z¹Lµ{¤¤ ¦³§âÅܼƩî¶} Split ¤S²Õ¦X Join §Ú¤£¬O«Ü¤F¸Ñ¨º¨Ç
¦³¨S¦³¤°»ò¿ìªk ¥i¥H¬Ý¨ìd(A.Value) ªºÈ¬O«ç»òÅܤƪº©O?
(§Ú¯uªº¬O¶W¶W¶W·s¤â¡A®ÇÃ䪺¤£n¯º ) |
|