|
楼主 |
发表于 2018-7-17 19:13
|
显示全部楼层
本帖最后由 office小白鼠 于 2018-7-17 19:19 编辑
麻烦各位大神抽空过来露两手,谢谢!用这个代码拆分附件没有反应,但是也不报错。其余我试过很多代码,都报错。这个代码和我的要求很接近,但是我不知道那里有问题,表示看不懂。
Sub 拆分()
Dim i%, r%
Dim wb As Workbook
Dim ws As Worksheet
Dim d As Object
Dim sp As Shape
Set d = CreateObject("scripting.dictionary")
Application.DisplayAlerts = False
Application.ScreenUpdating = False
With Worksheets("RRU网络割接专用模板")
r = .Cells(.Rows.Count, 1).End(xlUp).Row
arr = .Range("b1:b" & r)
For i = 6 To UBound(arr)
If Not d.exists(arr(i, 1)) Then
Set d(arr(i, 1)) = .Range("a1:q5")
End If
Set d(arr(i, 1)) = Union(d(arr(i, 1)), .Cells(i, 1).Resize(1, 17))
Next
End With
Application.SheetsInNewWorkbook = 1
For Each aa In d.keys
Set wb = Workbooks.Add
With wb
With .Worksheets("RRU网络割接专用模板")
d(aa).Copy .Range("a1")
.Name = aa
For Each sp In .Shapes
sp.Delete
Next
End With
.SaveAs Filename:=ThisWorkbook.path & "\" & aa & ".xls", FileFormat:=xlExcel8
.Close False
End With
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
|
|