分享我所知道的

自动拆分EXCEL+工作表VBA

Sub NewWk()
    Dim Wb As Workbook
    Dim Sh As Worksheet

    Set Wb = ThisWorkbook
    Application.SheetsInNewWorkbook = 1
    Application.DisplayAlerts = False
    For Each Sh In Sheets
        Set Wb = Workbooks.Add
        Sh.Copy after:=Wb.Sheets(1)
        Wb.Sheets(1).Delete
        Wb.SaveAs ThisWorkbook.Path & “\” & Sh.Name & “.xls”
        Wb.Close
    Next
    Application.DisplayAlerts = True
    Application.SheetsInNewWorkbook = 3
End Sub

Sub A()
    Dim Wbk As Workbook
    Dim Sht As Worksheet
    For Each Sht In ThisWorkbook.Sheets
        Sht.Copy
        ActiveWorkbook.Close savechanges:=True, Filename:=ThisWorkbook.Path & “\” & Sht.Name & “.xls”
    Next
End Sub

赞(0)
未经允许不得转载:追梦人博客 » 自动拆分EXCEL+工作表VBA
分享到:

评论 1

评论前必须登录!

 

  1. #0

    这是个实用的东西哦,先收藏着,以后肯定用得上。

    潍坊期货11年前 (2013-09-17)