|
参与一下。。。- Sub ykcbf() '//2024.3.16
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim zrr(1 To 1000)
- Set Fso = CreateObject("Scripting.FileSystemObject")
- Sheets("分类明细总表").Activate
- r = Cells(Rows.Count, 1).End(3).Row
- p = ThisWorkbook.Path & ""
- For i = 1 To r
- If InStr(Cells(i, 1), "物资名称") Then
- m = m + 1
- zrr(m) = Array(i, i)
- End If
- If i = r Then zrr(m)(1) = r
- If InStr(Cells(i + 1, 1), "物资名称") Then zrr(m)(1) = i
- Next
- For x = 1 To m
- fn = Cells(zrr(x)(0), 2)
- st = Split(Cells(zrr(x)(0) + 3, 1), ":")(1)
- p1 = p & "包(" & st & ")"
- If Not Fso.FolderExists(p1) Then Fso.CreateFolder p1
- Set Rng = Cells(zrr(x)(0) + 1, 1).Resize(zrr(x)(1) - zrr(x)(0), 9)
- Application.SheetsInNewWorkbook = 1
- Set wb = Workbooks.Add
- Rng.Copy
- wb.Sheets(1).Select
- [a1].PasteSpecial Paste:=xlPasteColumnWidths
- ActiveSheet.Paste
- ActiveSheet.[a1].Select
- Application.CutCopyMode = False
- wb.SaveCopyAs p1 & fn & ".xls"
- wb.Close
- Next
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|