ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro and Protected Sheet Problem (https://www.excelbanter.com/excel-programming/335193-macro-protected-sheet-problem.html)

Daniel R. Young

Macro and Protected Sheet Problem
 
I have macros that hide rows and I want to protect my sheet so individuals
will not be able to change any of the information. When the sheet is
protected the macro will not work. It goes to a debuger.

Is there a way to run my macros even though the sheet is protected?

Thank you,

Daniel

K Dales[_2_]

Macro and Protected Sheet Problem
 
Just turn protection off temporarily for the sheet:
Sub YourMacro()
Worksheets("SheetName").Unprotect
' macro code here
Worksheets("SheetName").Protect
End Sub
--
- K Dales


"Daniel R. Young" wrote:

I have macros that hide rows and I want to protect my sheet so individuals
will not be able to change any of the information. When the sheet is
protected the macro will not work. It goes to a debuger.

Is there a way to run my macros even though the sheet is protected?

Thank you,

Daniel


Otto Moehrbach

Macro and Protected Sheet Problem
 
In your macro, unprotect the sheet, hide the rows, protect the sheet. HTH
Otto
"Daniel R. Young" wrote in message
...
I have macros that hide rows and I want to protect my sheet so individuals
will not be able to change any of the information. When the sheet is
protected the macro will not work. It goes to a debuger.

Is there a way to run my macros even though the sheet is protected?

Thank you,

Daniel




STEVE BELL

Macro and Protected Sheet Problem
 
Daniel,

There is an alternative - check out the below code...
=======================================
Select UnProtected Cells ONLY
This will prevent users from clicking on protected cells on all
worksheets. Therefore, the warning message will not appear. The code
must be enterred in the ThisWorkbook module.

Note that the EnableSelection property must be reset each time the
workbook is opened as it defaults to xlNoRestrictions. The
worksheet(s)
must first be unprotected to set the EnableSelection property and then
must be protected for it to take effect.

Private Sub Workbook_Open()
Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
WS.Unprotect 'Password:="wxyz"
WS.EnableSelection = xlUnlockedCells
WS.Protect 'Password:="wxyz", UserInterfaceOnly:=True
Next
End Sub

Regards,
Greg Wilson 5/3/03


--
steveB

Remove "AYN" from email to respond
"Otto Moehrbach" wrote in message
...
In your macro, unprotect the sheet, hide the rows, protect the sheet.
HTH Otto
"Daniel R. Young" wrote in
message ...
I have macros that hide rows and I want to protect my sheet so individuals
will not be able to change any of the information. When the sheet is
protected the macro will not work. It goes to a debuger.

Is there a way to run my macros even though the sheet is protected?

Thank you,

Daniel






Daniel R. Young

Macro and Protected Sheet Problem
 
It worked thank you!

"Daniel R. Young" wrote:

I have macros that hide rows and I want to protect my sheet so individuals
will not be able to change any of the information. When the sheet is
protected the macro will not work. It goes to a debuger.

Is there a way to run my macros even though the sheet is protected?

Thank you,

Daniel



All times are GMT +1. The time now is 04:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com