hansgrandia
Board Regular
- Joined
- Jan 10, 2015
- Messages
- 53
Hello,
I'm trying to copy every sheet in workbook as separate file (on X drive) with the name of the sheet with below standing code. It now creates a single file with the name %20&%20ws.name%20&%20 including all sheets. What goes wrong here?
Thank you, Hans Grandia (Netherlands)
I'm trying to copy every sheet in workbook as separate file (on X drive) with the name of the sheet with below standing code. It now creates a single file with the name %20&%20ws.name%20&%20 including all sheets. What goes wrong here?
Thank you, Hans Grandia (Netherlands)
Code:
Sub SaveAsFile()
Application.ScreenUpdating = False
Dim ws As Worksheet
'eerste sheet selecteren
Worksheets(1).Activate
For Each ws In Worksheets
ws.Activate
With ActiveSheet
.SaveAs Filename:="X: & ws.name & .xlsx", FileFormat:=xlWorkbookDefault
.Close SaveChanges:=False
End With
Next
End Sub