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

[µo°Ý] ¤£¦P¸ê®Æ¤ñ¦r¦ê¤ñ¸û

[µo°Ý] ¤£¦P¸ê®Æ¤ñ¦r¦ê¤ñ¸û

½Ð°Ý¦³«e½ú­Ì¯àÀ°§Ú¸Ñµª¤@¤U¶Ü¡H
¤p§Ì¬Oµ{¦¡(VBA)·s¤â¡A¥Ø«e·Q¼g¤@­Ó¤pµ{¦¡¨ÓÀˬd¨Ó·½¸ê®Æ¬O§_¦³¥X²{¨Ò¥~¦r¦ê
½Ð¨£ªþ¥ótest_compare.rar¡C
·Q¤ñ¹ïSheet1 ªº C Äæ¦r¦ê¬O§_¦³¸òvendorcode¤W­±¥ô¦ó¤@­Ó¦r¦ê³£¤£²Å¦Xªº¡A­n¬O¦³¤£²Å¦Xªº´N¼g¦bcomp_rslt¸ê®Æªí¡C
¥Ø«esheet1ªºC11»PC12³£¬OÀ³¸Ó³Qµ{¦¡µo²{¨Ã¦L¦bcomp_rsltªº¦r¦ê¡A¦ý¬O°õ¦æ¤§«á³£·|¦L¥X¥ô¤@­Ó¦r¦ê(¤£À³¸Ó³Q¦L¥X¨Ó¦]¬°vendorcode¤W¦³)
½Ð°Ý¬O­þÃä§Ë¿ù¤F©O¥i§_µ¹¤p§Ì¤@¨Ç´£¥Ü¡A·PÁ¡I
  1. Sub compare()
  2. '

  3. '¨Ó·½¸ê®ÆªºÄæ¦ì¼Æ
  4. k = Sheets("sheet1").Cells(104689, 3).End(xlUp).Row

  5. '¤ñ¸û¸ê®ÆªºÄæ¦ì¼Æ
  6. p = Sheets("vendorcode").Cells(104689, 1).End(xlUp).Row



  7. For n = 2 To k
  8.   C = 1
  9.        For m = 1 To p
  10. '­n¬O¨Ó·½¸ê®Æ¦³­þ¤@Äæ©M¤ñ¸û¸ê®Æ¤£¦P¡A´N¦C¦b¤ñ¸ûµ²ªG¸ê®Æªícomp_rslt¤¤

  11.   If InStr(Sheets("sheet1").Cells(n, 3), Sheets("vendorcode").Cells(m, 1)) = 0 Then
  12.         Sheets("comp_rslt").Cells(C, 1).Value = Sheets("sheet1").Cells(n, 3)

  13.               


  14.    End If
  15.     C = C + 1
  16.     Next
  17.   Next

  18. End Sub
½Æ»s¥N½X

test_compare.rar (7.78 KB)

test_compare

¦^´_ 1# nyboy
¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub Ex()
  3.     Dim Ar As Variant, E As Range, St As String
  4.     With Sheets("vendorcode")
  5.         Ar = Application.Transpose(.Range("a1", .Range("a1").End(xlDown)).Value)  ' Application.Transpose Âà¸m
  6.         Ar = "," & Join(Ar, ",") & ","    '¤@ºû°}¦CÂର¦r¦ê
  7.     End With
  8.     With Sheets("SHEET1")
  9.         For Each E In .Range("C2", .Range("C2").End(xlDown))
  10.             If InStr(Ar, "," & E & ",") = 0 Then St = St & "," & E  '°O¿ý¦b¦r¦ê¤¤
  11.         Next
  12.     End With
  13.     If St <> "" Then
  14.         Ar = Split(Mid(St, 2), ",")         '¦r¦êÂର¤@ºû°}¦C
  15.         Sheets("comp_rslt").Range("A1").Resize(UBound(Ar) + 1) = Application.Transpose(Ar)
  16.     End If
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥i¥H¤F ¤Ó·PÁª©¥D!!

TOP

        ÀR«ä¦Û¦b : ¤£­nÀH¤ß©Ò±ý¡A­nÀH¤ß±Ð¨|¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD