|
更新一下。。。
- Sub ykcbf() '//2024.7.29 拆分
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- p = ThisWorkbook.Path & "\拆分结果"
- Set sh = ThisWorkbook.Sheets("Sheet")
- With sh
- arr = sh.UsedRange
- rr = .UsedRange.Find("GRAND TTL:").Row
- End With
- For i = 1 To UBound(arr)
- If arr(i, 1) = Empty And arr(i, 2) > 0 Then k = k + 1: d(k) = i
- Next
- On Error Resume Next
- For k = 1 To d.Count
- r1 = d(k)
- If k = d.Count Then r2 = UBound(arr) Else r2 = d(k + 1) - 1
- fn = Trim(arr(r1, 3))
- sh.Copy
- Set wb = ActiveWorkbook
- With wb.Sheets(1)
- Set Rng = Nothing
- .UsedRange.Offset(8).DrawingObjects.Delete
- .UsedRange.Offset(rr - 1).Clear
- For i = 10 To UBound(arr)
- If i < r1 Or i > r2 Then
- If Rng Is Nothing Then
- Set Rng = .Rows(i)
- Else
- Set Rng = Union(Rng, .Rows(i))
- End If
- End If
- Next i
- If Not Rng Is Nothing Then Rng.EntireRow.Delete
- End With
- wb.SaveAs p & fn
- wb.Close
- Next
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|