ollyhughes1982
Well-known Member
- Joined
- Nov 27, 2018
- Messages
- 793
- Office Version
- 365
- Platform
- MacOS
Hi,
I found the following code online (How to split a workbook to separate Excel files in Excel?). I hoped this would achieve my goal of saving all worksheets within a single .xlsx file and save (export / split) them to separate .xlsx files in the same file path location:
Sub Splitbook()
'Updateby20140612
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 & ".xlsx"
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Is there something that needs changing for macOS? I have done a debug and it seems to be something with the 9th (file path) line (part in red text).
The other VBA code that I've used from the same website previously has always worked on my Mac no problem.
Thanks in advance,
Olly.
I found the following code online (How to split a workbook to separate Excel files in Excel?). I hoped this would achieve my goal of saving all worksheets within a single .xlsx file and save (export / split) them to separate .xlsx files in the same file path location:
Sub Splitbook()
'Updateby20140612
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 & ".xlsx"
Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Is there something that needs changing for macOS? I have done a debug and it seems to be something with the 9th (file path) line (part in red text).
The other VBA code that I've used from the same website previously has always worked on my Mac no problem.
Thanks in advance,
Olly.