|
- Sub qs()
- Application.DisplayAlerts = False: Application.ScreenUpdating = False
- Dim arr, i, xb As Workbook, rng As Range
- arr = Sheet3.UsedRange
- With ThisWorkbook.Sheets("表")
- For i = 1 To UBound(arr)
- If InStr(arr(i, 1), "中间") Then
- s = s & "|" & i
- End If
- Next
- s = s & "|" & UBound(arr) + 2
- ar = Split(Mid(s, 2), "|")
- For i = 0 To UBound(ar) - 1
- Set rng = .Rows(ar(i) & ":" & ar(i + 1) - 2)
- Set xb = Workbooks.Add
- rng.Copy xb.Sheets(1).Range("a1")
- t = arr(ar(i), 1)
- mc = InStr(t, "名称:")
- mc2 = InStr(t, " 日期")
- m = Mid(t, mc + 3, mc2 - mc - 2)
- xb.Sheets(1).Name = m
- xb.SaveAs ThisWorkbook.Path & "\拆分后的表" & m & ".xlsx"
- xb.Close (True)
- Next
- End With
- Application.DisplayAlerts = True: Application.ScreenUpdating = True
- End Sub
复制代码 |
|