Unprotect shet, Password missed!

  • Thread starter Thread starter SpeeD
  • Start date Start date
S

SpeeD

Hi guys.

I´ve got the following code for unprotecting my sheets.
The problem is when i miss the password! Excell doesn´t
ask for it again or Stops the macro. It appears a Window
asking me to end or debug!

Sheets("GESTÃO").Select
ActiveSheet.Unprotect
Rows("7:11").Select
Selection.EntireRow.Hidden = False
Range("A1").Select
Sheets("ORÇAMENTO").Select
ActiveSheet.Unprotect
Rows("5:10").Select
Selection.EntireRow.Hidden = False
Range("A1").Select
Sheets(" AJUDA ! ").Select
Range("A1").Select

How can i make excell ask me for the passWord again or
simply stops the macro(or run another macro)

Thanks a lot!!!
 
SpeeD,

The error message is the result of trying to hide columns
on a sheet that didn't get unprotected.
You could place an
On Error Resume Next
at the beginning of your code and
On Error GoTo 0
at the end.
That will stop the error window from popping up but still
won't unprotect the sheet (or hide the columns).
Suggestion:
Why not include the password in the code???
ActiveSheet.Unprotect Password:="yourpassword"

John
 
Once again... Thanks a lot!!!!! :-)

It works fine!!
I want just some ppl to have acesse to some rows, that´s
why want ppl to insert a password.

A small question... how can i make the "Groups" butoom
useble in sheet portected mode? Exceell keeps me saying
that i have to unprotect the sheet (exacly what i dont
want to do!!)

Thanks Guys I´ve been great!
SpeeD
 
Back
Top