PDA

View Full Version : Solved: Unprotect Worksheets



drums4monty
10-06-2008, 02:11 AM
I have a workbook consisitng of 4 worksheets, these are all protected. When I receive the workbook in from outside I run macros on the sheets to format them etc. The macros do not work on protected sheets. Is it possible to run a macro first to unprotect these sheets before the main macro runs? For the sake of this lets call the sheets Sheet1, Sheet2, Sheet3 & Sheet4 and the password is abc.

Simon Lloyd
10-06-2008, 02:20 AM
As long as you know the password:

Dim Sh As Worksheet
For Each Sh in Sheets
Sh.Unprotect password:="abc"
Next Sh

drums4monty
10-06-2008, 03:25 AM
Thanks Simon, that works a treat.

Simon Lloyd
10-06-2008, 03:39 AM
If you only wanted to do specific sheets you would need to use an sheets array!