I have some VBA code that protects 3 sheets in a single workbook on opening.
Private Sub workbook_open()
Sheets("InputForm").Protect "password", UserInterfaceOnly:=True
Sheets("Invoice").Protect "password", UserInterfaceOnly:=True
Sheets("List").Protect "password", UserInterfaceOnly:=True
End Sub
i also have some code that shows/hides rows based on whether TRUE/FALSE
in a cell N14
Private Sub Worksheet_Calculate()
If ActiveSheet.Name = "InputForm" Then
Application.EnableEvents = False
Sheets("Invoice").Rows("57:123").Hidden = Range("N14").Value
Sheets("InputForm").Rows("57:94").Hidden = Range("N14").Value
Application.EnableEvents = True
Else
Application.EnableEvents = False
Application.EnableEvents = True
End If
End Sub
When i use a command button to execute some copy/paste code, i get an Error 1004, unable to set the hidden property of the range class. Debugging points to the Sheets("Invoice")...
line.
However, if i end the debugger and click the button again, it seems to work fine...?
Any help would be greatly appreciated
您需要先取消保护工作表,然后才能对其进行更改-即使使用VBA-这是相同的概念。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.