Sorry this may be simple but I'm not shure what I am doing wrong Can any one tell me why this is not working
Code:Sheets(Array("MO-TS", "MO-DS", "MO-CG")).Unprotect password:="RTA"
Printable View
Sorry this may be simple but I'm not shure what I am doing wrong Can any one tell me why this is not working
Code:Sheets(Array("MO-TS", "MO-DS", "MO-CG")).Unprotect password:="RTA"
You can't use the Protect method with an array, it must be by singular value, e.g. looping through each of those sheets and (un)protecting on an iteration. Some functions cannot be performed like this. My biggest pet peeve with this is not being able to do Data Validation to the same cell in each worksheet (manually) at the same time.
To test out what I'm talking about, select a sheet, press and hold the Shift key, then select another sheet - group any number of sheets. Now go to the Tools menu, select Protection, not that Protect Sheet is greyed out. Try this with other menus and menu options to see what you can/can't use with sheets in an array.
Hi there,
If you only have the three to do, how about this as an alternative?
Code:Sub Unprotect()
dim pwrd as string
pwrd = "RTA"
Sheets("MO-TS").unprotect password:=pwrd
Sheets("MO-DS").unprotect password:=pwrd
Sheets("MO-cg").unprotect password:=pwrd
End Sub
thanks that was what i needed to know