derek.hughes
Board Regular
- Joined
- Mar 16, 2012
- Messages
- 53
I found this code on the interwebs and it works great for splitting my worksheets to separate workbooks. However, I am wondering if someone can help me tweak it so it preserves the password protection and unchecks "display gridlines" when it separates.
I am more concerned with the password than the gridlines piece if you can help.
Thank you!
Derek
I am more concerned with the password than the gridlines piece if you can help.
Thank you!
Derek
Code:
Option Explicit
Sub Split2MultipleWorkBOOKS()
Dim sheet As Worksheet, SheetName$, MyFilePath$, N&
MyFilePath$ = ActiveWorkbook.path & "\" & _
Left(ThisWorkbook.Name, Len(ThisWorkbook.Name) - 4)
With Application
.ScreenUpdating = False
.DisplayAlerts = False
' End With
On Error Resume Next '<< a folder exists
MkDir MyFilePath '<< create a folder
For N = 1 To Sheets.Count
Sheets(N).Activate
SheetName = ActiveSheet.Name
Cells.Copy
Workbooks.Add (xlWBATWorksheet)
With ActiveWorkbook
With .ActiveSheet
.Paste
.Name = SheetName
[A1].Select
End With
'save book in this folder
.SaveAs Filename:=MyFilePath _
& "\" & SheetName & ".xlsx"
.Close SaveChanges:=True
End With
.CutCopyMode = False
Next
End With
Sheet1.Activate
End Sub
Last edited: