Code to Require Password to Unhide Rows on Already Password Protected Sheet

WadeExcel

New Member
Joined
Oct 27, 2009
Messages
33
The worksheet is already passord protected. I have assorted macros created to unlock the sheet with the password (without any user interface), perform a procedure and then reprotect the sheet. On the payroll portion of the worksheet, if the rows have been hidden, what is the code to require the user to provide a password that will unhide those rows (without unprotecting the entire sheet)?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Ultimately the sheet will need unprotected but you could do this all programmatically

Code:
Sub Unlockhide()
Dim pass As String
pass = InputBox("Please enter your password!", "Password Prompt")
Select Case pass
    Case "Password": With ActiveSheet
                        .Unprotect "SheetPWord"
                        .Rows("2:3").EntireRow.Hidden = False
                        .Protect "SheetPWord"
                    End With
    Case Else: MsgBox "Incorrect Password!"
End Select
End Sub
 
Upvote 0
Hi this is exactly what I need!!

How would it look if I don't want to protect the sheet? I just want rows 118-143 to need a password to both hide and unhide
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top