View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Janice Hanna Janice Hanna is offline
external usenet poster
 
Posts: 1
Default Command Button not working once sheet is protected


Gentleman, thank you for your input. Deleting a row is definitely too
drastic. As I indicated I have the command buttons doing what I need
them to do, that is until I protect the worksheet so that the user can
not alter its original form. Here is a sample of the code for expanding
the rows:

Private Sub CommandButton4_Click()
Dim StartRow As Long
Dim EndRow As Long
StartRow = 13
EndRow = 14
Rows(StartRow & ":" & EndRow).Hidden = False
End Sub

Then here is the code for the button that hides the rows:

Private Sub CommandButton3_Click()
Dim StartRow As Long
Dim EndRow As Long
StartRow = 13
EndRow = 14
Rows(StartRow & ":" & EndRow).Hidden = True
End Sub

I have tried the following change and VB does not like it. Since I am
new to VB code and just learning from a book, I have no idea what I am
missing. I am researching both through my book and through the
Internet. But I wanted to see if either of you could give me a hint.

Private Sub CommandButton1_Click()
ActiveSheet.Unprotect password:="corp_rate"

Dim StartRow As Long
Dim EndRow As Long
StartRow = 8
EndRow = 11
Rows(StartRow & ":" & EndRow).Hidden = True
ActiveSheet.Protect password:"corp_rate"

End Sub

Thanks!
Janice


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!