Protecting sheet is giving me error message with my macros. - Unable to set hidden property of range class. HELP!

Anonymous
2022-10-18T12:49:16+00:00

I am trying to Show / Hide row(s). Unprotected, it works fine. However, when I protect and try to use the macro buttons, I get an "Unable to set hidden property of range class." What am I doing wrong?

Here is my code:

Public Sub AllowMacros()

Me.Protect UserInterfaceOnly:=True

End Sub

Sub Hide_Answer()

'

' Hide_Answer Macro

'

'

Rows("19:20").Select 

Selection.EntireRow.Hidden = True   (<- this part is highlighted )

Range("B19:Q20").Select 

End Sub

Sub Show_Answer()

'

' Show_Answer Macro

'

'

Rows("19:20").Select 

Selection.EntireRow.Hidden = False 

Range("B19:Q20").Select 

End Sub

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

6 answers

Sort by: Most helpful
  1. Anonymous
    2022-10-18T16:52:42+00:00

    Thank you, Jan. You have been extremely helpful.

    Question. Is there a way to prevent others from sliding up or down when in the worksheet? Is that possible?

    Was this answer helpful?

    0 comments No comments