Want to unhide hidden rows while sheet is locked

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
617
Office Version
  1. 2019
Platform
  1. Windows
I have locked my worksheet to protect formulas, but also want the option of being able to hide and unhide rows while locked (I have grouped various rows so that I can toggle hiding and unhiding of these rows). Is there a way of being able to do this without having to unlock the sheet all the time?

Dan
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi,

Are you looking for something like this?
Code:
Sub Test()

ActiveSheet.Unprotect Password:="abc"

If Rows("20:20").EntireRow.Hidden = True Then
    Rows("20:20").EntireRow.Hidden = False
    ActiveSheet.Protect Password:="abc"
    Exit Sub
ElseIf Rows("20:20").EntireRow.Hidden = False Then
    Rows("20:20").EntireRow.Hidden = True
    ActiveSheet.Protect Password:="abc"
End If

End Sub

Jai
 
Upvote 0
What does this code do? Does it temporarily unlock the sheet so that it can unhide the rows if they are hidden or hide the rows if thy are already unhidden? How would I implement it, would it need to be linked to a toggle button to do this? If that is what the code would do, and that is what needs to be done to solve my problem, then that would be very useful.
 
Upvote 0
I've just tried the code, but cannot work out how to test run it without having to create a button to activate it. Is there a way of manually running code to test it?
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

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