|
楼主 |
发表于 2022-12-1 18:32
|
显示全部楼层
麻烦了,请问总表在标题行增加了一行空白的,明细表怎么生成
- Private Sub CommandButton1_Click()
- tms = Timer
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- For Each sht In Sheets
- If sht.Name <> ActiveSheet.Name And sht.Name <> "目录" Then sht.Delete
- Next
- Application.DisplayAlerts = True
- Set d = CreateObject("scripting.dictionary")
- arr = Range("a2").CurrentRegion
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 27)) Then
- Set d(arr(i, 27)) = Range("a" & i).Resize(1, 66)
- Else
- Set d(arr(i, 27)) = Union(d(arr(i, 27)), Range("a" & i).Resize(1, 66))
- End If
- Next
- x = d.keys
- For k = 1 To UBound(x)
- Set Sh = ActiveWorkbook.Sheets.Add(, after:=ActiveSheet)
- Sh.Name = x(k)
- d.items()(k).Copy Sh.Range("a" & 2)
- Rows("1:1").Copy Sh.Range("a1")
- Next
- Application.ScreenUpdating = True
- 'MsgBox Format(Timer - tms, "拆分完成,共耗时:0.00秒"), 64, "时间统计"
- End Sub
复制代码 |
|