且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

关闭工作簿时隐藏特定的工作表

更新时间:2023-12-02 08:28:16

此处设置了可见的false,您可以使用 Workbook_BeforeClose 方法,如下所示:

Here for setting visible false, you can use Workbook_BeforeClose method as follow:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Worksheets("Team_1").Visible = False
    Worksheets("Team_1_sub").Visible = False

    'must save, if not save, it is not effect.
    Me.Save

End Sub

该方法的引用为一件事是,此方法必须在 ThisWorkBook 模块中.

One thing is that this method must have in the ThisWorkBook module.

对于下一个问题,您应该说更多,例如,哪个表用于哪个用户和密码.因为您的代码足以解决您的问题.它可以根据您的要求使用.

For next question, you should say more like, which sheets for which user and password. Because you code is enough for your question. It can use for your requirement.