|
参与一下。。。
- Sub ykcbf() '//2024.5.26
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- fn = [{"甲","乙"}]
- Set sh = ThisWorkbook.Sheets("表")
- With sh
- For x = 1 To UBound(fn)
- c = 1 + (x - 1) * 5
- r = .Cells(Rows.Count, c).End(3).Row
- arr = .Cells(1, c).Resize(r, 4)
- With Sheets(fn(x))
- .Cells.ClearContents
- .Name = fn(x)
- .[a1].Resize(UBound(arr), UBound(arr, 2)) = arr
- .Range("A:D").Columns.AutoFit
- End With
- Sheets(fn(x)).Copy
- Set wb = ActiveWorkbook
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "请选择文件夹"
- .InitialFileName = ThisWorkbook.Path & ""
- If .Show = -1 Then
- p = .SelectedItems(1) & ""
- End If
- End With
- wb.SaveAs p & fn(x), 56
- wb.Close
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|