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

[µo°Ý] ¦p¦ó§Q¥ÎVBA¤@Áä ¦Û°Ê¤ñ¹ï¤u§@ªíA & BªºCÄæ¬Û²§¸¹½X¡H

¸Õ¸Õ¬Ý:
1. ´¡¤JUserForm1, ¨Ã³]©w Caption ªºÄݩʬ°"¤ñ¹ïµ²ªG"
2. ¦b UserForm1 ¤¤´¡¤J Label1, ListBox1 ¤Î CommandButton1
3. ³]©w UserForm1.CommandButton1 ªº Caption Äݩʬ°"½T©w"
4. Double Click UserForm1.CommandButton1, ¦b½s¿èµøµ¡¤¤Áä¤J¤U¦C VBA code:
  1. Private Sub CommandButton1_Click()
  2.         Unload Me
  3.     End Sub
½Æ»s¥N½X
5. Â÷¶}VBA½s¿èµøµ¡¦^¨ì sheetA, ¦b sheetA ¤¤´¡¤JCommandButton1,
    ¨Ã³]©w Caption ªºÄݩʬ°"«ö§Ú¤ñ¹ï"
6. Double Click CommandButton1, ¦b½s¿èµøµ¡¤¤Áä¤J¤U¦C VBA code:
  1. Private Sub CommandButton1_Click()
  2.     Dim rngA As Range, rngB As Range, rngC As Range
  3.     Dim cel As Range, foundCel As Range
  4.     Dim cntLB As Integer, R As Integer
  5.     Set rngA = [A!C3:C79]
  6.     Set rngB = [B!C3:C1000]
  7.     Set rngC = [C!C3:C500]
  8.     '
  9.     '¥ý¤ñ¹ïrngB ¤ÎrngC, ¨Ã±N¬Û²§¸¹½X¦s¨ì¼È¦s°Ï[B!D:D]
  10.     '¦A­«³] rngB, ¶i¦Ó¤ñ¹ïrngB ¤ÎrngA
  11.     '
  12.     UserForm1.ListBox1.Clear       '²M°£ListBox
  13.     [B!D:D] = ""     '²M°£¼È¦s°Ï
  14.     R = 1
  15.     For Each cel In rngC
  16.         If cel <> "" Then
  17.             Set foundCel = rngB.Find(cel, LookAt:=xlWhole, SearchDirection:=2)
  18.             
  19.             'foundCel Is Nothing ªí¥Ü¨S§ä¨ì, §Y rngCªºcel »P rngB ¤£­«ÂÐ
  20.             If foundCel Is Nothing Then
  21.                 R = R + 1
  22.                 Sheets("B").Cells(R, 4) = cel '±N rngCªºcel ¥[¨ì ¼È¦s°Ï
  23.             End If
  24.         End If
  25.     Next
  26.    
  27.     Set rngB = [B!C3:D1000]      '¦A­«³] rngB
  28.     For Each cel In rngB
  29.         If cel <> "" Then
  30.             Set foundCel = rngA.Find(cel, LookAt:=xlWhole, SearchDirection:=2)
  31.             
  32.             'foundCel Is Nothing ªí¥Ü¨S§ä¨ì, §Y rngBªºcel »P rngA ¤£­«ÂÐ
  33.             If foundCel Is Nothing Then
  34.                 UserForm1.ListBox1.AddItem cel    '±N rngBªºcel ¥[¨ì ListBox1
  35.             End If
  36.         End If
  37.     Next
  38.     cntLB = UserForm1.ListBox1.ListCount
  39.     If cntLB = 0 Then
  40.         MsgBox "§ä¤£¨ì¬Û²§¸¹½X!!", vbCritical
  41.     Else
  42.         UserForm1.Label1.Caption = "¦@¦³" & cntLB & "µ§¬Û²§¸¹½X," & Chr(10) _
  43.                  & "¦p¤U©Ò¦C¡G"
  44.         UserForm1.Show
  45.     End If
  46. End Sub
½Æ»s¥N½X
test.gif

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡µLªk¾B¾×¡j©È®É¶¡®ø³u¡Aªá¤F³\¦h¤ß¦å¡A·QºÉ¦U¦¡¤èªk­n¾B¾×®É¶¡¡Aµ²ªG¬O¡G®ö¶O¤F§ó¦h®É¶¡¡A¥B¤@µL©Ò¦¨¡I
ªð¦^¦Cªí ¤W¤@¥DÃD