|
Option Explicit
Sub test()
Dim ar, br(1 To 2), d As Object, i&, j&, k&, f$, s$, t$
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
With Worksheets(1)
t = .[a1]
ar = .Range("b3:b" & .Cells(.Rows.Count, 1).End(xlUp).Row)
For i = 1 To UBound(ar)
s = ar(i, 1)
If Not d.exists(s) Then d(s) = ""
Next
br(1) = .Name
End With
With Worksheets(2)
ar = .Range("c2:c" & .Cells(.Rows.Count, 3).End(xlUp).Row)
For i = 1 To UBound(ar)
s = ar(i, 1)
If Not d.exists(s) Then d(s) = ""
Next
br(2) = .Name
End With
Application.DisplayAlerts = False
For i = 0 To d.Count - 1
s = d.keys()(i)
f = ThisWorkbook.Path & "\" & s & t & ".xlsx"
Worksheets(br).Copy
With ActiveWorkbook
With .Worksheets(1)
For j = .Cells(.Rows.Count, 1).End(xlUp).Row To 3 Step -1
If .Range("b" & j) <> s Then .Rows(j).Delete
Next
k = 0
For j = 3 To .Cells(.Rows.Count, 1).End(xlUp).Row
k = k + 1
.Range("a" & j) = k
Next
.DrawingObjects.Delete
End With
With .Worksheets(2)
For j = .Cells(.Rows.Count, 3).End(xlUp).Row To 2 Step -1
If .Range("c" & j) <> s Then .Rows(j).Delete
Next
End With
.SaveAs f, 51
.Close
End With
Next
Set d = Nothing
Application.DisplayAlerts = True
Application.ScreenUpdating = True
MsgBox "OK!", 64
End Sub |
-
-
总表.rar
31.99 KB, 下载次数: 20
迟来的答题
评分
-
3
查看全部评分
-
|