Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes - is that a problem now?
Mike "Ron de Bruin" wrote in message ... 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes
You use sheets in your loop There are no cells in a chart sheet that's why your code blow. Change sheets to worksheets in the code(2*) and it will work for all the worksheets -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Mike" wrote in message ... Yes - is that a problem now? Mike "Ron de Bruin" wrote in message ... 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That now works fine.
Cheers for the help - I was sure that it was something quick and easy to correct. Mike "Ron de Bruin" wrote in message ... Yes You use sheets in your loop There are no cells in a chart sheet that's why your code blow. Change sheets to worksheets in the code(2*) and it will work for all the worksheets -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Mike" wrote in message ... Yes - is that a problem now? Mike "Ron de Bruin" wrote in message ... 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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That now works fine.
Cheers for the help - I was sure that it was something quick and easy to correct. Mike "Ron de Bruin" wrote in message ... Yes You use sheets in your loop There are no cells in a chart sheet that's why your code blow. Change sheets to worksheets in the code(2*) and it will work for all the worksheets -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Mike" wrote in message ... Yes - is that a problem now? Mike "Ron de Bruin" wrote in message ... 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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
cheers
"Ron de Bruin" wrote in message ... Yes You use sheets in your loop There are no cells in a chart sheet that's why your code blow. Change sheets to worksheets in the code(2*) and it will work for all the worksheets -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Mike" wrote in message ... Yes - is that a problem now? Mike "Ron de Bruin" wrote in message ... 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 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You are welcome
-- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Mike" wrote in message ... cheers "Ron de Bruin" wrote in message ... Yes You use sheets in your loop There are no cells in a chart sheet that's why your code blow. Change sheets to worksheets in the code(2*) and it will work for all the worksheets -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Mike" wrote in message ... Yes - is that a problem now? Mike "Ron de Bruin" wrote in message ... 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 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you have merged cells on any of the sheets. Just a guess, but that can
sometimes interfere when you are changing properties. -- Regards, Tom Ogilvy "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unprotect workbook | Excel Discussion (Misc queries) | |||
Unprotect workbook | Excel Discussion (Misc queries) | |||
How to unprotect a workbook by macro? | Excel Discussion (Misc queries) | |||
Unprotect Workbook | Excel Discussion (Misc queries) | |||
Unprotect a Workbook | Excel Programming |