又一次搬家囉! https://blog.inndy.tw

over 3 years ago

今天被問了奇怪的問題,覺得有價值筆記下來,VBA不解釋

split-sheets-to-files.vbs
Sub Main()
    If MsgBox("Hi, Split sheets to files?", vbYesNo) = vbNo Then Exit Sub
    Dim xPath As String
    xPath = Application.ActiveWorkbook.Path
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    For Each xWs In ThisWorkbook.Sheets
        xWs.Copy
        Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls"
        Application.ActiveWorkbook.Close False
    Next
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    MsgBox "Done! Files are in..." & vbNewLine & Application.ActiveWorkbook.Path
End Sub
← 處理你無用的CapsLock ht editor 編譯筆記 →
 
comments powered by Disqus