如何保护工作表名称不是整个工作表? [英] How to Protect the sheet name not the entire sheet?

查看:137
本文介绍了如何保护工作表名称不是整个工作表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过防止


  • 对表单名称进行任何更改来保护工作表名称,或

  • 正在删除的工作表。

必须完成而不使用保护整个工作表,使用 / code>或保护工作簿选项。

This must be done without protecting the entire sheet using the Protect Sheet or Protect Workbook options.

有没有办法使用VBA? / p>

Is there any way to do this with VBA?

推荐答案


  1. 右键单击要保护的工作表选项卡

  2. 查看代码

  3. 复制并粘贴到代码中

此代码禁用删除当工作表激活时,控制工作表(但不要右键单击单元格)菜单。当表单被禁用时,该控件被启用

This code disables the delete control on the sheet (but not right click on cell) menu when the sheet is activated. The control is enabled when the sheet is de-activated

当表单被禁用时,该代码也将命名为NameOfSheet。这是一个防范工作表被重命名的解决方法。

The code will also name the sheet "NameOfSheet" when the sheet is de-activated. This is a workaround to prevent the sheet being renamed

Private Sub Worksheet_Activate()
Application.CommandBars.FindControl(ID:=847).Enabled = False
End Sub

Private Sub Worksheet_Deactivate()
Application.CommandBars.FindControl(ID:=847).Enabled = True
Me.Name = "NameOfSheet"
End Sub

这篇关于如何保护工作表名称不是整个工作表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆