I have a workbook with different worksheets and I want to save each of them as a separate xls file but protected (needs a code to open it).
Thanks!
I have a workbook with different worksheets and I want to save each of them as a separate xls file but protected (needs a code to open it).
Thanks!
[VBA]
Option Explicit
Sub CopySaveProtect()
Dim PW As String
Dim pth As String
Dim sh As Worksheet
pth = ActiveWorkbook.Path
PW = "PW"
For Each sh In Sheets
sh.Copy
With ActiveWorkbook
.SaveAs pth & "\" & sh.Name & ".xls", Password:=PW
.Close
End With
Next
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'