|
Sub 拆分()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each sh In Sheets
If sh.Index > 1 Then
sh.Delete
End If
Next sh
Application.DisplayAlerts = True
Set sh = Sheets("Table 1")
With sh
r = .Cells(Rows.Count, 1).End(xlUp).Row
Dim rr()
ReDim rr(1 To r)
For i = 1 To r
If InStr(.Cells(i, 1), "表一、基本信息") > 0 Then
n = n + 1
rr(n) = i
End If
Next i
n = n + 1
rr(n) = r
If n = 1 Then MsgBox "找不到表一、基本信息标志!": End
For i = 1 To n - 1
ks = rr(i)
If i < n - 1 Then
js = rr(i + 1) - 1
Else
js = rr(i + 1)
End If
mc = .Cells(ks + 10, 2)
sh.Copy after:=Sheets(Sheets.Count)
With ActiveSheet
.UsedRange.Clear
sh.Rows(ks & ":" & js).Copy .[a1]
.Name = mc
For Each shp In .Shapes
shp.Delete
Next shp
End With
Next i
.Select
End With
Application.ScreenUpdating = False
MsgBox "拆分完毕!"
End Sub
|
|