|
楼主 |
发表于 2021-12-29 08:54
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
大神我还有问题,就是说我每个表中S巴拉巴拉的那个工作表是需要出图的,现在出不了图我是需要在代码哪部分做出怎样的改变
Sub 按字段拆分成独立工作薄()
Application.ScreenUpdating = False
Dim i, j
Dim arr, brr
Dim sht As Worksheet, mypath$, temp$
'选择保存工作薄的文件路径
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "请选择生成新工作薄的存储文件夹!"
.AllowMultiSelect = False
If .Show Then
mypath = .SelectedItems(1)
Else
Exit Sub
End If
End With
If Right(mypath, 1) <> "\" Then mypath = mypath & "\"
arr = Sheet1.Range("B5:L139")
ReDim brr(1 To UBound(arr), 1 To 1)
For j = 1 To UBound(arr, 2)
For i = 1 To UBound(arr)
brr(i, 1) = arr(i, j)
Next
temp = j & ".xlsm"
' 赋值,复制三份工作表生成新的工作薄,并保存到指定路径
Sheets(Array("Donnees", "Synthesis", "Calculs")).Select
Sheets(Array("Donnees", "Synthesis", "Calculs")).Copy
Sheets("Calculs").Visible = False
Range("D5:D139") = brr
ActiveWorkbook.SaveCopyAs mypath & temp
ActiveWorkbook.Close False
ReDim brr(1 To UBound(arr), 1 To 1)
k = 0
Next
Application.ScreenUpdating = True
End Sub
|
|