View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Macro to unprotect workbook

Hi Mike

Do you have a Chart sheet in the workbook??

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Mike" wrote in message ...
Hi

I have the following macros coded to protect and unprotect a workbook I'm
working on. However, when I try to unprotect the workbook using
UnprotectAllSheets(), it keeps failing, particularly with reference to the
part ".Cells.FormulaHidden = False". This had worked fine for a while, but
now that other macros have been put into the workbook, it now seems to fail.

Has anybody any thoughts on what might be causing this? Thanks in advance
for any help.

Mike


Sub UnprotectAllSheets()

Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
With Sheets(n)
.Unprotect Password:="password"
.Cells.FormulaHidden = False
End With
Next n
Application.ScreenUpdating = True

End Sub


Sub ProtectAllSheets()

Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
Sheets(n).Protect Password:="password"

Next n
Application.ScreenUpdating = True

End Sub


Sub HideFormulaCode()

Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
With Sheets(n)
.Cells.FormulaHidden = True
.Protect Password:="password"

End With
Next n
Application.ScreenUpdating = True

End Sub