Andy & Kate
New Member
- Joined
- May 11, 2005
- Messages
- 14
I have written a macro to unfilter a workbook when it is saved but it also needs to unprotect and then protect up the workbook. My problem is that the protection needs to allow certain formatting. I have tried the following but it doesn't allow the formating:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("OUTPUTS").Select
ActiveSheet.Unprotect ("investment")
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveSheet.Protect ("investment")
AllowFormattingCells = True
AllowFormattingColumns = True
AllowFormattingRows = True
AllowFiltering = True
AllowEditRanges = True
End Sub
Any suggestions would be greatly appreciated.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("OUTPUTS").Select
ActiveSheet.Unprotect ("investment")
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveSheet.Protect ("investment")
AllowFormattingCells = True
AllowFormattingColumns = True
AllowFormattingRows = True
AllowFiltering = True
AllowEditRanges = True
End Sub
Any suggestions would be greatly appreciated.