Hi,
I'm trying to write a macro to help me manage protecting the excel files I work with. I want to be able to select (group) a selection of sheets then press a button to password protect only those sheets then ungroup them.
I will be using it as a personal macro rather than tied to a specific file so I can't assign named sheets to an array etc...
I know that because the sheets are grouped it's causing the protect routine to fail. Any suggestions for how to get round this ?
Can I assign the selected (grouped) sheets to an array and then loop through to protect ?
How do I change the "NameSheet","NamedSheet2" to only the selected sheet names ?
Any advise would be welcome
I'm trying to write a macro to help me manage protecting the excel files I work with. I want to be able to select (group) a selection of sheets then press a button to password protect only those sheets then ungroup them.
I will be using it as a personal macro rather than tied to a specific file so I can't assign named sheets to an array etc...
I know that because the sheets are grouped it's causing the protect routine to fail. Any suggestions for how to get round this ?
Code:
For Each sht In ActiveWindow.SelectedSheets
sht.Protect Password:=strPassword
Next sht
Can I assign the selected (grouped) sheets to an array and then loop through to protect ?
How do I change the "NameSheet","NamedSheet2" to only the selected sheet names ?
Code:
Set group = Sheets(Array("Sheet1", "Sheet2", "Sheet3"))
For Each sht In group
sht.Activate
ActiveSheet.Protect "Password"
Next sht
Any advise would be welcome
Last edited: