ChatGpt Excel batch split sheet to file

Today , I have a performance question for excel.

My team need to split a huge excel sheeets to every single excel file for every sheet.

Then I think I can use #ChatGPT macro to solve this problem.

Promote:

Give me a demo to splite every excel sheet to a single file in current directory.

Then I Got the right answer in 3 seconds. Amazing.

Sub SaveSheetsAsXlsx()
Dim ws As Worksheet
Dim wb As Workbook
Dim savePath As String

Application.ScreenUpdating = False

Set wb = ActiveWorkbook

For Each ws In wb.Worksheets
savePath = ThisWorkbook.Path & “\” & ws.Name & “.xlsx”
ws.Copy
Set wbNew = ActiveWorkbook
wbNew.SaveAs Filename:=savePath, FileFormat:=xlOpenXMLWorkbook
wbNew.Close SaveChanges:=False
Next ws

Application.ScreenUpdating = True

End Sub

Alt+F11, paste above source code to excel, press F5.

Then the files comes.

About me:

This post is come from www.hot583.com, you can share/use it with the post  original link for free.

But pay attention of any  risk yourself.

微信原文《The End》

今日热点在看SAP HOT583

1人评论了“ChatGpt Excel batch split sheet to file”

评论区已关闭。