如何使用vba在excel中的单元格中锁定数据 [英] How to Lock the data in a cell in excel using vba
本文介绍了如何使用vba在excel中的单元格中锁定数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想阻止其他人使用VBA编辑我的Excel表格中的单元格内容。是否可以这样做?
解决方案
您可以先选择不希望受到保护的单元格(作为用户可以通过将它们的锁定状态设置为False:
工作表(Sheet1)。范围(B2:C3 ).Locked = False
然后,您可以保护工作表,而所有其他单元格将保护。
执行此操作的代码仍然允许您的VBA代码修改单元格:
工作表(Sheet1 ).Protect UserInterfaceOnly:= True
或
$($)code code code code code code code $
I want to stop others from editing the cell contents in my excel sheet using VBA. Is it possible to do this?
解决方案
You can first choose which cells you don't want to be protected (to be user-editable) by setting the Locked status of them to False:
Worksheets("Sheet1").Range("B2:C3").Locked = False
Then, you can protect the sheet, and all the other cells will be protected. The code to do this, and still allow your VBA code to modify the cells is:
Worksheets("Sheet1").Protect UserInterfaceOnly:=True
or
Call Worksheets("Sheet1").Protect(UserInterfaceOnly:=True)
这篇关于如何使用vba在excel中的单元格中锁定数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文