I already set item manually with name “Test” in Class AllowEditRange. I Just need to change range of this item by VBA , But I could not. I tried the following code , but it do nothing (no error raised) Thanks for everyone can help.
Option Explicit
Option Compare Text
Private Sub Modify_User_EditRange()
Dim ws As Worksheet
Set ws = ThisWorkbook.ActiveSheet
ws.Protection.AllowEditRanges("Test").Range = ws.Range("A2:A8")
End Sub
CodePudding user response:
ws.Protection.AllowEditRanges("Test").Range
returns a Range
object so to modify it, you need to use the Set
statement:
Set ws.Protection.AllowEditRanges("Test").Range = ws.Range("A2:A8")