|
楼主 |
发表于 2016-9-11 21:22
|
显示全部楼层
本帖最后由 adminsong 于 2016-9-11 21:27 编辑
谢谢您的回复,我按照您的模板自己改了一下,时间可以放在指定的位置,就是有个问题,按照之前的表格命名规则的话提示错位,我现在只能是按照页数命名新表,能不能麻烦您再给修改下代码,拆分后的新表按照工程名称和编号命名,新生成的模板表格中有一个表格会自动带拆分的按钮,能否给取消掉?这是我改后的代码
- Sub 按钮1_Click()
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- For j = 2 To UBound(arr)
- If d.exists(arr(j, 1) & "##" & arr(j, 2) & "##" & arr(j, 3) & "##" & arr(j, 4)) Then
- Set d(arr(j, 1) & "##" & arr(j, 2) & "##" & arr(j, 3) & "##" & arr(j, 4)) = Union(Cells(j, 5).Resize(1, 10), d(arr(j, 1) & "##" & arr(j, 2) & "##" & arr(j, 3) & "##" & arr(j, 4)))
- Else
- Set d(arr(j, 1) & "##" & arr(j, 2) & "##" & arr(j, 3) & "##" & arr(j, 4)) = Cells(j, 5).Resize(1, 10)
- End If
- Next j
- For j = 0 To d.Count - 1
- Sheets(2).Copy after:=Sheets(2)
- arr = Split(d.keys()(j), "##")
- Sheets(3).Name = "第" & (j) & "页"
- Sheets(3).Cells(4, 3) = arr(1)
- Sheets(3).Cells(3, "k") = arr(0)
- Sheets(3).Cells(4, "j") = arr(2)
- Sheets(3).Cells(19, "b") = arr(3)
- d.items()(j).Copy Sheets(3).[b7]
- Next j
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|