![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
I have a series of sheet and graphs as sheet tabs in the same work book and i would like the macro code to protect and unprotect them all rather than just the worksheets. I use
For Each ws in Sheets ws.protect Password:="password" Next ws End sub Thanks |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Sydney/Brisbane , Australia
Posts: 539
|
this is code from NateO
Sub alShts2() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Protect "password" 'change 'protect' to 'unprotect' to unprotect each sheet Next ws End Sub |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
thanks a million for the advice
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
that works for the worksheets but stops at the charts tabs.
Is there soemthing missing? |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Qroozn, I appreciate the reference, seems like a long time ago that you and I were talking about flashing cells on the old board....
To the matter at hand. Try: Code:
Sub alShts3() Dim ws As Worksheet For Each ws In ThisWorkbook.Worksheets ws.Protect "password" 'change 'protect' to 'unprotect' to unprotect each sheet Next ws For Each ws In ThisWorkbook.Charts ws.Protect "password" 'change 'protect' to 'unprotect' to unprotect each sheet Next ws End Sub _________________ Cheers, NateO ![]() [ This Message was edited by: NateO on 2002-05-08 21:43 ] |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
That creates a run time error 13
type mismatch |
|
|
|
|
|
#7 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Bad variable. Try:
Code:
Sub Pro() Dim ws As Worksheet, ch As Chart For Each ws In ThisWorkbook.Worksheets ws.Protect "ps" Next ws For Each ch In ThisWorkbook.Charts ch.Protect "ps" Next ch End Sub |
|
|
|
|
|
#8 |
|
Board Regular
Join Date: May 2002
Location: Sydney, Australia
Posts: 298
|
excellent result thanks for the assistance u r a legend
|
|
|
|
|
|
#9 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
You're welcome. Have a good one!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|