I am new with VBA My worksheet works as normal with the command button. When i tried to protect my worksheet, right click on the worksheet tab and selected protect sheet with password. Once i completed it, i generated my command button in the worksheet, it showed error as below
I did not use any code for protection but right click on the worksheet and clicked on protect sheet. It worked to other sheets except the sheet I am using command button.
The code I used for the command button works well when the worksheet is not protected as below.
Sub Hide_Unhide()
If Range("A4").Value = "Yes" Then
Rows("4:4").EntireRow.Hidden = True
Else
Rows("4:4").EntireRow.Hidden = False
End If
If Range("A5").Value = "Yes" Then
Rows("5:5").EntireRow.Hidden = True
Else
Rows("5:5").EntireRow.Hidden = False
End If
End Sub