dsheard2015
Board Regular
- Joined
- May 10, 2016
- Messages
- 134
Hello,
I have numerous worksheets that I am trying to add "allow users to edit ranges" permissions. There are a lot of worksheets so I am hoping to accomplish this using vba and written in to the sheet code. I have come up with a code but it returns a "run-time error 91; object variable not set" message. I'm not even sure if this is the correct way of getting what I hope for so I am very open to any changes.
Any help I can get with this is greatly appreciated?
Thanks,
Dave
I have numerous worksheets that I am trying to add "allow users to edit ranges" permissions. There are a lot of worksheets so I am hoping to accomplish this using vba and written in to the sheet code. I have come up with a code but it returns a "run-time error 91; object variable not set" message. I'm not even sure if this is the correct way of getting what I hope for so I am very open to any changes.
Any help I can get with this is greatly appreciated?
Thanks,
Dave
Code:
Sub SetAllowEditRanges()
Dim Sht As Worksheet
Sht.Protection.AllowEditRanges.Add Title:="Grade", Range:=Range("C28:L28,C61:L61,C94:L94,C127:L127,C160:L160,C193:L193,C226:L226"), Password:=Sheets("Worksheet Names").Range("O11").Value
Sht.Protection.AllowEditRanges.Add Title:="Student Initials", Range:=Range("C29:L29,C62:L62,C95:L95,C128:L128,C161:L161,C194:L194,C227:L227"), Password:=Sheets("Worksheet Names").Range("O11").Value
End Sub