ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Macro- not re-password protecting (https://www.excelbanter.com/excel-discussion-misc-queries/195485-macro-not-re-password-protecting.html)

Roady

Macro- not re-password protecting
 
Hi:

I am using a macro that involves unprotecting and protecting the sheet at
the beginning and end of the macro. I have used this same code in a different
spreadsheet's macro and it worked fine (including the allow filter part).
However, when I run it on this spreadsheet, it re-protects it at the end, but
WITHOUT the password. the code I am using is as follows:

Sub Macro1()
ActiveSheet.Unprotect Password:="Stars"

(All Macro details go here...)

ActiveSheet.Protect Password:="Stars"
ActiveSheet.Protect AllowFiltering:=True

End Sub

Do you have any idea why it protects it but without the necessary password?
thank you!

Gord Dibben

Macro- not re-password protecting
 
The second Activesheet.Protect has no password so wipes out the first
Activesheet.Protect

Use this construct

With ActiveSheet
.Protect Password:="Stars"
.EnableAutoFilter = True
End With


Gord Dibben MS Excel MVP

On Fri, 18 Jul 2008 15:39:00 -0700, Roady
wrote:

Hi:

I am using a macro that involves unprotecting and protecting the sheet at
the beginning and end of the macro. I have used this same code in a different
spreadsheet's macro and it worked fine (including the allow filter part).
However, when I run it on this spreadsheet, it re-protects it at the end, but
WITHOUT the password. the code I am using is as follows:

Sub Macro1()
ActiveSheet.Unprotect Password:="Stars"

(All Macro details go here...)

ActiveSheet.Protect Password:="Stars"
ActiveSheet.Protect AllowFiltering:=True

End Sub

Do you have any idea why it protects it but without the necessary password?
thank you!




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

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