|
写的不好,清测试,可行的话给个鲜花
- Sub tt()
- Application.ScreenUpdating = False
- a1 = Cells(Rows.Count, 1).End(3).Row
- a2 = Cells(Rows.Count, 6).End(3).Row
- ReDim m(a1 - 2)
- ReDim n(a2 - 2)
- Set arr1 = Range(Cells(2, 1), Cells(a1, 2))
- Set arr2 = Range(Cells(2, 6), Cells(a2, 7))
- For aa1 = 2 To a1
- m(aa1 - 2) = Cells(aa1, 1) & Cells(aa1, 2)
- Next
- For aa2 = 2 To a2
- n(aa2 - 2) = Cells(aa2, 6) & Cells(aa2, 7)
- Next
- Cells(2, 13).Resize(a1 - 1, 1) = Application.Transpose(m)
- Cells(2, 14).Resize(a2 - 1, 1) = Application.Transpose(n)
- '----------------------------sheet2-------------------------------
- Dim b(100000)
- For Each mm In m
- j = j + 1
- If Columns(14).Find(mm) Is Nothing Then
- b(i) = j + 1
- Cells(b(i), 1).Resize(1, 5).Copy
- Sheets(2).Activate
- Cells(Rows.Count, 1).End(3).Offset(1, 0).Select
- Sheets(2).Paste
- i = i + 1
- Sheets(1).Activate
- End If
- Next
- '----------------------------sheet3-------------------------------
- i = 0
- j = 0
- Dim c(100000)
- For Each nn In n
- j = j + 1
- If Columns(13).Find(nn) Is Nothing Then
- c(i) = j + 1
- Cells(c(i), 6).Resize(1, 5).Copy
- Sheets(3).Activate
- Cells(Rows.Count, 1).End(3).Offset(1, 0).Select
- Sheets(3).Paste
- i = i + 1
- Sheets(1).Activate
- End If
- Next
- '----------------------------sheet4-------------------------------
- i = 0
- j = 0
- Dim d1(100000)
- For Each mm In m
- j = j + 1
- If Not Columns(14).Find(mm) Is Nothing Then
- d1(i) = j + 1
- Cells(d1(i), 1).Resize(1, 5).Copy
- Sheets(4).Activate
- Cells(Rows.Count, 1).End(3).Offset(1, 0).Select
- Sheets(4).Paste
- i = i + 1
- Sheets(1).Activate
- End If
- Next
- i = 0
- j = 0
- Dim d2(100000)
- For Each nn In n
- j = j + 1
- If Not Columns(13).Find(nn) Is Nothing Then
- d2(i) = j + 1
- Cells(d2(i), 6).Resize(1, 5).Copy
- Sheets(4).Activate
- Cells(Rows.Count, 6).End(3).Offset(1, 0).Select
- Sheets(4).Paste
- i = i + 1
- Sheets(1).Activate
- End If
- Next
- '----------------------------End-------------------------------
- Sheets(1).Columns("M:N").ClearContents
- Set arr1 = Nothing
- Set arr2 = Nothing
- Erase m, n, b, c, d1, d2
- MsgBox "End!"
- Application.ScreenUpdating = True
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|