语言吧

<tfoot draggable='sEl'></tfoot>

在EXCE中通过VB脚本拆分大表并生成多个文件

Sub xxx()

Dim reg As Range

Dim i As Long

Dim x, pth As String

pth = ThisWorkbook.Path

 For i = 2 To 10000 Step 500

   Set reg = Nothing

   Set reg = Sheets("Sheet1").Rows(i & ":" & i + 499)

  x = Sheets("Sheet1").Cells(i, 1) & ""

  Sheets.Add.Name = x

  Sheets(x).[A1] = Sheets("Sheet1").[A1]

  Sheets(x).[B1] = Sheets("Sheet1").[B1]

  reg.Copy Sheets(x).Rows(2)

  Sheets(x).Copy

  Application.DisplayAlerts = False

  With ActiveWorkbook

    .SaveAs Filename:=pth & "\" & x & ".xlsx"

    .Close

  End With

  ThisWorkbook.Sheets(x).Delete

  Application.DisplayAlerts = True

 Next

End Sub


查看更多关于在EXCE中通过VB脚本拆分大表并生成多个文件的详细内容...

  阅读:2130次
  阅读:2130次