Split multiple sheets in excel into separate excel files

1. Question:

  The company is doing a project, and the message sent to the user is an excel file containing multiple sheet pages.

  However, when actually processing the message data, it is necessary to split the excel file into multiple independent message excel files

 

2. Solution:

  (1) Copy one by one, create a new file, and generate a new sheet file. It is very troublesome when there are many sheets.

  (2) Use office's macro tool to automatically split files

 

3. Operation steps:  

  Note: This operation takes wps as an example, please test others by yourself

  (1) Download [wps vba macro plugin]

  (2) Click [Development Tools]--"[vba Editor]--"[Insert]--"[Module]

  (3) Copy the following code:

Private Sub split worksheet()

Dim sht As Worksheet

Dim MyBook As Workbook

Set MyBook = ActiveWorkbook

For Each sht In MyBook.Sheets

sht.Copy

ActiveWorkbook.SaveAs Filename: =MyBook.Path & "\" & sht.Name, FileFormat:=xlNormal 'Save the workbook as EXCEL default format

ActiveWorkbook.Close

Next

MsgBox "The file has been split!"

End Sub

  (4) Click Run to split the file to the same level directory of the modified message, and name the new file with the name of the sheet

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324927995&siteId=291194637