|
- Private Sub CommandButton1_Click()
- Dim Arr1, Arr2, i&, Myr&, l1, l2, scl3, d
- Set d = CreateObject("Scripting.Dictionary")
- l1 = TextBox1.Text
- l2 = TextBox2.Text
- scl3 = TextBox3.Text
- Cells(2, scl3).Resize(500, 1).ClearContents
- Myr = Cells(65536, l1).End(xlUp).Row
- Arr1 = Cells(2, l1).Resize(Myr - 1)
- Myr = Cells(65536, l2).End(xlUp).Row
- Arr2 = Cells(2, l2).Resize(Myr - 1)
- For i = 1 To UBound(Arr1)
- d(Arr1(i, 1)) = ""
- Next
- n = 1
- Select Case scl3
- Case "C", "c"
- For i = 1 To UBound(Arr2)
- If Not d.exists(Arr2(i, 1)) Then
- n = n + 1
- Cells(n, scl3) = Arr2(i, 1)
- End If
- Next
- Cells(1, scl3) = "差异列"
- Case "D", "d"
- For i = 1 To UBound(Arr2)
- If d.exists(Arr2(i, 1)) Then
- n = n + 1
- Cells(n, scl3) = Arr2(i, 1)
- End If
- Next
- Cells(1, scl3) = "重复列"
- Case "E", "e"
- For i = 1 To UBound(Arr2)
- d(Arr2(i, 1)) = ""
- Next
- Cells(2, scl3).Resize(d.Count, 1) = Application.Transpose(d.keys)
- Cells(1, scl3) = "全部数据"
- End Select
- End Sub
复制代码 |
|