• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro to unhide password protected sheet

Injinia

Member
Hi,


I have a macro that copies data from one sheet to another. These sheets are now hidden and the workbook/worksheet is protected. The macro now does not work as it supposed to. It runs(no error) but the data is not copied.


I would need some help with a macro that unprotects the workbook, runs the macro, protects it again without the use having to input the password.


-Injinia
 
Hi Injinia,


Are you asking for a hack? If yes, then I don't think any of the open forums will help you do that!


Regards,
 
Hi shrivallabha,


Sorry I should have being more clear. The document is password protected by me!!! I am not asking for a hack :). I would like a macro that runs my password to unlock the sheet, have another macro run while the sheet is unlocked then runs again to lock the hidden sheet using my password.


This scenario will then enable other users run macros without having to input my password to unlock the hidden sheets every single time.


-Injinia
 
You could use a pair of macros like this:

[pre]
Code:
Const pWord = "abc123"
Sub UnlockSheet(sName As String)
Worksheets(sName).Unprotect pWord
End Sub
Sub ProtectSheet(sName As String)
Worksheets(sName).Protect pWord
End Sub
And then in your regular macro, do this:

Sub NormalStuff()
Dim Sheet_I_work_on As String

Sheet_I_work_on = "Sheet1"

UnlockSheet (Sheet_I_work_on)
'do some stuff

ProtectSheet (Sheet_I_work_on)
End Sub
[/pre]
Just some samples to get you started.
 
Back
Top