在Excel 2016中将一个工作簿中的多个工作表拆分成多个工作簿,在开发工具中的vba 模块中输入一下代码(并修改savepath的值为要存储的路径),然后运行即可。
Sub SplitWorkbook()Dim srcWorkbook As WorkbookDim srcWorksheet As WorksheetDim newWorkbook As WorkbookDim newWorksheet As WorksheetDim cell As RangeDim savePath As String' 设置源工作簿Set srcWorkbook = ThisWorkbook' 设置保存路径savePath = "C:\Temp\" ' 设置保存路径' 循环遍历源工作簿中的每个工作表For Each srcWorksheet In srcWorkbook.Worksheets' 创建一个新的工作簿Set newWorkbook = Workbooks.Add' 将源工作表复制到新工作簿srcWorksheet.Copy Before:=newWorkbook.Sheets(1)' 设置新工作簿的工作表Set newWorksheet = newWorkbook.Sheets(1)' 删除新工作簿中的其他工作表Application.DisplayAlerts = FalseDo While newWorkbook.Sheets.Count > 1newWorkbook.Sheets(2).DeleteLoopApplication.DisplayAlerts = True' 保存新工作簿newWorkbook.SaveAs savePath & srcWorksheet.Name & ".xlsx"newWorkbook.CloseNext srcWorksheet' 关闭源工作簿srcWorkbook.Close
End Sub