ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   hide unhide rows -Protected sheet (https://www.excelbanter.com/excel-discussion-misc-queries/238991-hide-unhide-rows-protected-sheet.html)

Wanna Learn

hide unhide rows -Protected sheet
 
Hello I have a command button in a form
Private Sub CommandButton1_Click()
'hide rows
Dim myRng As Range

Set myRng = Me.Range("a32:a36")

myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)

but when I protect the form the button does not work. I also have the rows
and columns hidden
How can I correct this ?
thanks


End Sub

Otto Moehrbach[_2_]

hide unhide rows -Protected sheet
 
Include code in your macro to Unprotect the sheet, do your stuff, protect
the sheet. Record a macro to find the protect/unprotect code. HTH Otto
"Wanna Learn" wrote in message
...
Hello I have a command button in a form
Private Sub CommandButton1_Click()
'hide rows
Dim myRng As Range

Set myRng = Me.Range("a32:a36")

myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)

but when I protect the form the button does not work. I also have the
rows
and columns hidden
How can I correct this ?
thanks


End Sub




Eduardo

hide unhide rows -Protected sheet
 
Hi,
include in your macro unprotect and protect

'To protect

Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.Protect Password:="geo"
Next ws

'To unprotect
Set MySheets = ActiveWindow.SelectedSheets
For Each ws In MySheets
ws.Select
ws.Unprotect Password:="geo"
Next ws
'


"Wanna Learn" wrote:

Hello I have a command button in a form
Private Sub CommandButton1_Click()
'hide rows
Dim myRng As Range

Set myRng = Me.Range("a32:a36")

myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)

but when I protect the form the button does not work. I also have the rows
and columns hidden
How can I correct this ?
thanks


End Sub


Jim Thomlinson

hide unhide rows -Protected sheet
 
Private Sub CommandButton1_Click()
'hide rows
Dim myRng As Range

Set myRng = Me.Range("a32:a36")
me.unprotect 'Password:="Tada"
myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)
me.protect 'Password:="Tada"
--
HTH...

Jim Thomlinson


"Wanna Learn" wrote:

Hello I have a command button in a form
Private Sub CommandButton1_Click()
'hide rows
Dim myRng As Range

Set myRng = Me.Range("a32:a36")

myRng.EntireRow.Hidden = Not (myRng(1).EntireRow.Hidden)

but when I protect the form the button does not work. I also have the rows
and columns hidden
How can I correct this ?
thanks


End Sub



All times are GMT +1. The time now is 02:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com