Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / September 2006

Tip: Looking for answers? Try searching our database.

Macro to unprotect with password

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian.Hastings82@gmail.com - 28 Sep 2006 14:38 GMT
Hi Excel People

I need a macro that when pressed asks for the passwork to unprotect a
cell/worsheet.

If possible i would then like another input box asking for a number
which it inserts into this cell then locks again.

any ideas?

Thanks

Brian
Tieske - 29 Sep 2006 00:30 GMT
Create a cell with the password you need and name it "GetThePassword". Then
try the code below. You should be able to adapt it to suit your needs.

'Make workbook ready for development
'
Sub StartDevelopment()

Dim mySheet As Worksheet
Dim Password As String

   ' read the password from the named range
   Password = [GetThePassword]

   'check password
   If UCase(InputBox("Password: ")) <> UCase(Password) Then
       MsgBox "Wrong password.", vbOKOnly + vbCritical, "Sorry..."
       Exit Sub
   End If

   'unprotect the workbook, and then all the sheets
   ActiveWorkbook.Unprotect (Password)
   For Each mySheet In Sheets
       With mySheet
           .Unprotect (Password) 'unprotect the sheet
           .Visible = xlSheetVisible 'unhide the sheet
       End With
   Next

End Sub

> Hi Excel People
>
[quoted text clipped - 9 lines]
>
> Brian

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.