|
参与一下。。。总表拆分- Sub ykcbf() '//2024.6.29
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- For Each sht In Sheets
- If InStr("基础数据源|加工合同模板", sht.Name) = 0 Then sht.Delete
- Next
- With Sheets("基础数据源")
- r = .Cells(Rows.Count, 6).End(3).Row
- arr = .[a1].Resize(r, 16)
- End With
- For i = 5 To UBound(arr)
- If arr(i, 2) = Empty Then arr(i, 2) = arr(i - 1, 2)
- s = arr(i, 2)
- If Not d1.exists(s) Then
- d1(s) = Array(arr(i, 5), arr(i, 3), arr(i, 4))
- End If
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(i) = i
- Next
- On Error Resume Next
- For Each k In d.keys
- Sheets("加工合同模板").Copy After:=Sheets(Sheets.Count)
- Set sht = Sheets(Sheets.Count)
- m = 0
- With sht
- .Name = d1(k)(0)
- .[b6] = d1(k)(0)
- .[b7] = d1(k)(1)
- .[b8] = d1(k)(2)
- .[l2] = k
- ReDim brr(1 To 20, 1 To 20)
- For Each kk In d(k).keys
- m = m + 1
- For j = 6 To UBound(arr)
- brr(m, j - 5) = arr(kk, j)
- Next
- Next
- .[a13].Resize(m, 11) = brr
- End With
- Next
- Sheets("基础数据源").Activate
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|