- ©«¤l
- 522
- ¥DÃD
- 36
- ºëµØ
- 1
- ¿n¤À
- 603
- ÂI¦W
- 0
- §@·~¨t²Î
- win xp sp3
- ³nÅ骩¥»
- Office 2003
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-12-13
- ³Ì«áµn¿ý
- 2021-7-11
|
¸Õ¸Õ¬Ý:
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:- Private Sub CommandButton1_Click()
- Unload Me
- 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:- Private Sub CommandButton1_Click()
- Dim rngA As Range, rngB As Range, rngC As Range
- Dim cel As Range, foundCel As Range
- Dim cntLB As Integer, R As Integer
- Set rngA = [A!C3:C79]
- Set rngB = [B!C3:C1000]
- Set rngC = [C!C3:C500]
- '
- '¥ý¤ñ¹ïrngB ¤ÎrngC, ¨Ã±N¬Û²§¸¹½X¦s¨ì¼È¦s°Ï[B!D:D]
- '¦A«³] rngB, ¶i¦Ó¤ñ¹ïrngB ¤ÎrngA
- '
- UserForm1.ListBox1.Clear '²M°£ListBox
- [B!D:D] = "" '²M°£¼È¦s°Ï
- R = 1
- For Each cel In rngC
- If cel <> "" Then
- Set foundCel = rngB.Find(cel, LookAt:=xlWhole, SearchDirection:=2)
-
- 'foundCel Is Nothing ªí¥Ü¨S§ä¨ì, §Y rngCªºcel »P rngB ¤£«ÂÐ
- If foundCel Is Nothing Then
- R = R + 1
- Sheets("B").Cells(R, 4) = cel '±N rngCªºcel ¥[¨ì ¼È¦s°Ï
- End If
- End If
- Next
-
- Set rngB = [B!C3:D1000] '¦A«³] rngB
- For Each cel In rngB
- If cel <> "" Then
- Set foundCel = rngA.Find(cel, LookAt:=xlWhole, SearchDirection:=2)
-
- 'foundCel Is Nothing ªí¥Ü¨S§ä¨ì, §Y rngBªºcel »P rngA ¤£«ÂÐ
- If foundCel Is Nothing Then
- UserForm1.ListBox1.AddItem cel '±N rngBªºcel ¥[¨ì ListBox1
- End If
- End If
- Next
- cntLB = UserForm1.ListBox1.ListCount
- If cntLB = 0 Then
- MsgBox "§ä¤£¨ì¬Û²§¸¹½X!!", vbCritical
- Else
- UserForm1.Label1.Caption = "¦@¦³" & cntLB & "µ§¬Û²§¸¹½X," & Chr(10) _
- & "¦p¤U©Ò¦C¡G"
- UserForm1.Show
- End If
- End Sub
½Æ»s¥N½X
|
|