如何隐藏和取消隐藏受保护工作表上的行,而不会出现错误1004? [英] How to hide and unhide rows on protected sheet, without error 1004?
本文介绍了如何隐藏和取消隐藏受保护工作表上的行,而不会出现错误1004?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
隐藏和取消隐藏工作表中的行时,出现错误1004
.
I'm getting error 1004
when hiding and unhiding rows on a sheet.
此工作表受保护,但是允许用户设置行格式,从而允许用户隐藏和取消隐藏行.
This sheet is protected but does allow the user to format rows which allows the user to hide and unhide rows.
尽管该代码确实起作用,但它给出了错误1004
,告诉我该工作表已被保护,需要删除它.我相信问题是因为我正在选择要隐藏/取消隐藏的单元格.我如何隐藏/取消隐藏单元格范围?
Although the code does work, it gives an error 1004
telling me the sheet is protected which I need to get rid of. I believe the issue is because I'm selecting the cells I want to hide/unhide. How do I just hide/unhide the cell range?
Sub Show_menu()
Rows("20:20").Select
Rows("20:44").Select
Selection.EntireRow.Hidden = False
Rows("45:45").Select
Rows("45:128").Select
Selection.EntireRow.Hidden = True
End Sub
推荐答案
尝试一下:
Sub Show_menu()
Sheets("yoursheetname").Unprotect Password:="abc"
Rows("20:20").Select
Rows("20:44").Select
Selection.EntireRow.Hidden = False
Rows("45:45").Select
Rows("45:128").Select
Selection.EntireRow.Hidden = True
Sheets("yoursheetname").Protect Password:="abc", AllowFormattingRows:=True
End Sub
已添加:
AllowFormattingCells:=True ' to allow formatting
和
Sheets("yoursheetname").EnableSelection = xlUnlockedCells ' to allow unlocked cell in protected book
这篇关于如何隐藏和取消隐藏受保护工作表上的行,而不会出现错误1004?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文