[英]How do I hide a sheet using VBA?
Microsoft Excel 2010 has Sheet1, Sheet2, Sheet3. Microsoft Excel 2010具有Sheet1,Sheet2,Sheet3。
On Sheet 1, the page is locked. 在工作表1上,页面被锁定。 It contains fields that reference Sheet3.
它包含引用Sheet3的字段。
For example, Sheet1 on A2 is titled "Name" and B2 has =Sheet3!B2. 例如,在A2上的Sheet1标题为“名称”,而B2具有= Sheet3!B2。
On Sheet3, A2 is titled "Name" and B2 is blank unless the user fills it in. Of course Sheet3 Cell B2 auto populates into Sheet1. 在Sheet3上,除非用户填写,否则A2的标题为“名称”,而B2为空白。当然,Sheet3单元格B2自动填充到Sheet1中。
On Sheet 3, I have more similar fields that are editable by users such as address and phone number. 在工作表3上,我有更多类似的字段可供用户编辑,例如地址和电话号码。 However, I would like to hide Sheet3 by creating a button that hides Sheet3 once clicked.
但是,我想通过创建一个单击一次即可隐藏Sheet3的按钮来隐藏Sheet3。 I don't want people that are emailed this file to see this Sheet3 with all the information on it.
我不希望通过电子邮件发送此文件的人看到此Sheet3及其所有信息。 It will confuse automated systems.
它将混淆自动化系统。
I've researched all that I could and found some codes that hides a sheet after information is typed into a certain field but I was not sure how to apply that code to a button. 我已经尽力研究了,发现了一些将信息输入到特定字段后隐藏工作表的代码,但是我不确定如何将该代码应用于按钮。 The purpose for this button is not all my users are tech savvy so this is a quick way to allow them to hide the sheet without the fuss.
此按钮的用途不是我的所有用户都精通技术,因此这是一种允许他们隐藏表格而不必大惊小怪的快速方法。 The button would go on Sheet3 as well.
该按钮也将出现在Sheet3上。
I found a code that could help if someone knows some VBA to convert it to the use of a button. 我发现了一个代码,如果有人知道一些VBA可以将其转换为按钮的使用,该代码将有所帮助。 This code says B6 and B7, hide the sheet.
此代码显示B6和B7,隐藏工作表。 I am really lost how to use button click command with this almost close formula.
我真的迷失了如何在这个几乎封闭的公式中使用按钮单击命令。
Sub ShowHideWorksheets()
Dim Cell As Range
For Each Cell In Range("B6:B7")
ActiveWorkbook.Worksheets(Cell.Value).Visible = Not
ActiveWorkbook.Worksheets(Cell.Value).Visible
Next Cell
End Sub
almost, try: 几乎可以尝试:
ActiveWorkbook.Worksheets(Cell.Value).Visible = xlSheetHidden
or if you want to hide the sheet, and not allow the user to see it in the hidden sheet collection: 或者如果您想隐藏工作表,并且不允许用户在隐藏的工作表集合中看到它:
ActiveWorkbook.Worksheets(Cell.Value).Visible = xlSheetVeryHidden
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.