|
参与一下。。。- Sub ykcbf() '//2024.2.21
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- fns = [{"留1","留2"}]
- b = [{9,15}]
- Set d = CreateObject("Scripting.Dictionary")
- Set ws = ThisWorkbook
- p = ws.Path & ""
- fn = Split(ws.Name, ".")(0)
- For x = 1 To UBound(b)
- With Sheets(fns(x))
- r = .Cells(Rows.Count, b(x)).End(3).Row
- For i = 10 To r
- s = .Cells(i, b(x))
- d(s) = ""
- Next
- End With
- Next
- On Error Resume Next
- For Each k In d.keys
- ws.Sheets(fns).Copy
- Set wb = ActiveWorkbook
- For x = 1 To UBound(b)
- With wb.Sheets(fns(x))
- .DrawingObjects.Delete
- r = .Cells(Rows.Count, b(x)).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .Range("a9").Resize(r + 100, c)
- .Range("a9").Resize(r + 100, c).Copy .[a1]
- .UsedRange.Offset(1).Clear
- ReDim brr(1 To UBound(arr), 1 To c)
- m = 0
- For i = 2 To UBound(arr)
- s = arr(i, b(x))
- If s = k Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- brr(m, j) = arr(i, j)
- Next
- End If
- Next
- .[a2].Resize(m, UBound(arr, 2)) = brr
- End With
- Next
- wb.SaveAs p & fn & "-" & k
- wb.Close
- Next
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|