• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Use list of worksheet names to set UserInterfaceOnly on Opening

Cammandk

Member
The code below sets the UserInterfaceOnly for Sheet13 when the workbook open.
I have many many sheets that need to be set - some with different passwords. Can I use a listing of worksheet names somewhere that can then be used in an array or something rather than having to type them individually?

DK

Sheet13.Protect , UserInterFaceOnly:=True
With Sheet13
.Protect Password:=[PWGeneralSheets], UserInterFaceOnly:=True, AllowFormattingCells:=True
.EnableSelection = xlUnlockedCells
 
Something like this perhaps?
Code:
Sub SetInterface()
Dim MyTable As Range
Dim sName As String
Dim sPass As String
Dim c As Range

'List of sheet names
Set MyTable = Worksheets("SetupSheet").Range("A1:A10")

For Each c In MyTable.Columns(1).Cells
    sName = c.Value
    sPass = c.Offset(0, 1).Value
   
    With Worksheets(sName)
        .Protect Password:=[PWGeneralSheets], UserInterFaceOnly:=True, AllowFormattingCells:=True
        .EnableSelection = xlUnlockedCells
    End With
Next c
End Sub
 
Back
Top