保护 Excel 中的单元格,但允许通过 VBA 脚本修改这些单元格 [英] Protecting cells in Excel but allow these to be modified by VBA script

查看:41
本文介绍了保护 Excel 中的单元格,但允许通过 VBA 脚本修改这些单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Excel,其中允许用户输入某些字段并保护其他单元格.我已经使用了 Tools Protect 表,但是这样做之后我无法更改 VBA 脚本中的值.我需要限制工作表以停止用户输入,同时允许 VBA 代码根据某些计算更改单元格值.

I am using Excel where certain fields are allowed for user input and other cells are to be protected. I have used Tools Protect sheet, however after doing this I am not able to change the values in the VBA script. I need to restrict the sheet to stop user input, at the same time allow the VBA code to change the cell values based on certain computations.

推荐答案

尝试使用

Worksheet.Protect "Password", UserInterfaceOnly := True

如果 UserInterfaceOnly 参数设置为 true,则 VBA 代码可以修改受保护的单元格.

If the UserInterfaceOnly parameter is set to true, VBA code can modify protected cells.

这篇关于保护 Excel 中的单元格,但允许通过 VBA 脚本修改这些单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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