|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.12.11
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim zrr(1 To 1000)
- p = ThisWorkbook.Path & ""
- rr = 5: bt = 1: c = 2
- Set sh = ThisWorkbook.Sheets("Sheet1")
- With sh
- r = .UsedRange.Find("*", , -4163, , 1, 2).Row
- arr = .[a1].Resize(r, c)
- Set bth = .Rows(bt).EntireRow
- End With
- For i = bt + 1 To UBound(arr)
- If arr(i, 1) <> arr(i - 1, 1) Then m = m + 1: zrr(m) = Array(i, i)
- If i = r Then zrr(m)(1) = r
- If i < r Then
- If arr(i, 1) = arr(i - 1, 1) And arr(i, 1) <> arr(i + 1, 1) Then zrr(m)(1) = i
- End If
- Next
- Application.SheetsInNewWorkbook = 1
- For x = 1 To m
- r1 = zrr(x)(0): r2 = zrr(x)(1)
- n = r2 - r1 + 1
- numSheets = Int(n / rr) + 1
- k = 0
- For i = 1 To numSheets
- k = k + 1
- rr1 = r1 + (i - 1) * rr
- rr2 = Application.Min(r1 + i * rr - 1, r2)
- Set wb = Workbooks.Add
- With Sheets(1)
- bth.Copy .[a1]
- Set Rng = sh.Range(sh.Cells(rr1, 1), sh.Cells(rr2, c))
- Set destRange = .[a2]
- Rng.Copy Destination:=destRange
- End With
- wb.SaveAs Filename:=p & arr(r1, 1) & "-" & k
- wb.Close
- Next
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|