PDA

View Full Version : [SOLVED:] Array not working



mduff
02-09-2005, 10:25 AM
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


Sheets(Array("MO-TS", "MO-DS", "MO-CG")).Unprotect password:="RTA"

Zack Barresse
02-09-2005, 10:44 AM
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.

Ken Puls
02-09-2005, 10:45 AM
Hi there,

If you only have the three to do, how about this as an alternative?


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

mduff
02-09-2005, 10:55 AM
thanks that was what i needed to know