AllowEditRange 对象 (Excel)

代表受保护的工作表上可进行编辑的单元格。

备注

使用 AllowEditRanges 集合的 Add 方法或 Item 属性可返回 AllowEditRange 对象。

返回 AllowEditRange 对象后,可以使用 ChangePassword 方法更改密码以访问可在受保护的工作表上编辑的区域。

示例

在此示例中,Microsoft Excel 允许编辑活动工作表上的“A1:A4”区域,通知用户,然后更改此指定区域的密码,并通知用户此更改。

Sub UseChangePassword() 
 
 Dim wksOne As Worksheet 
 Dim wksPassword As String 
 
 Set wksOne = Application.ActiveSheet 
 
 wksPassword = InputBox ("Enter password for the worksheet") 
 
 ' Establish a range that can allow edits 
 ' on the protected worksheet. 
 wksOne.Protection.AllowEditRanges.Add _ 
 Title:="Classified", _ 
 Range:=Range("A1:A4"), _ 
 Password:=wksPassword 
 
 MsgBox "Cells A1 to A4 can be edited on the protected worksheet." 
 
 ' Change the password. 
 
 wksPassword = InputBox ("Enter the new password for the worksheet") 
 
 wksOne.Protection.AllowEditRanges(1).ChangePassword _ 
 Password:=wksPassword 
 
 MsgBox "The password for these cells has been changed." 
 
End Sub

方法

属性

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。