Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hide & display rows in excel with locked cells 1

Status
Not open for further replies.

Queryman

Programmer
Nov 4, 2002
243
US
I need to lock certain cells but also have the ability to have the user hide or display the rows with the locked cells. Is that possible with VBA using a macro button?



Michael

 
Hi,,

In VBA...

1) Unprotect sheet
2) do sheet operation unable to do on protected sheet
3) Protect sheet

:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
How can you have the user use this without supplying them the password to the sheet?
Private Sub Switch_view()
ActiveSheet.Unprotect
Rows("11:33").Select
Selection.EntireRow.Hidden = True
Range("C2:E2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

Private Sub Most_likely_view()
ActiveSheet.Unprotect
Rows("11:34").Select
Selection.EntireRow.Hidden = False
Range("C2:E2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub



Michael

 
Code:
Sub Switch_view()
ActiveSheet.Unprotect password:=whatever
    Rows("11:33").Select
    Selection.EntireRow.Hidden = True
    Range("C2:E2").Select
     ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True,  password:=whatever
End Sub
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top