![]() |
![]() |
|
|||||||
| 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 |
|
New Member
Join Date: Mar 2002
Location: Nanaimo, BC
Posts: 49
|
I've looked, but haven't been able to find the code for unprotecting sheets and workbooks at the beginning of a macro and protecting again at the end. Unfortunately, my help in Excel or VBA isn't installed so I can't look there.
Also I was wondering if there was a way to make it so cells on the sheet cannot be selected (when you protect the sheet you are still able to select cells). Thank You! Kyle |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Mar 2002
Location: Wellington
Posts: 104
|
Hi,
From recording a macro, the codes for unprotect and protecting a worksheet and workbook are: ActiveSheet.Unprotect password:="Testing" ActiveSheet.Protect password:="Testing", DrawingObjects:=True, Contents:=True, Scenarios:=True ActiveWorkbook.Protect Structure:=True, Windows:=False ActiveWorkbook.Unprotect And as for have cells can not be selected, I am hot too sure whether hiding those cells would do the trick. For example, hide the whole column or something, and the having the sheet protected, then users can not edit them. HTH |
|
|
|
|
|
#3 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Sub Protect_Noselection() ActiveSheet.Protect "test", True, True, True ActiveWorkbook.Protect "test", True, True ActiveSheet.EnableSelection = xlNoSelection '============= 'Do your thing '============= ActiveSheet.Unprotect "test" ActiveWorkbook.Unprotect "test" End Sub Note XlNoselection will only take effect when the sheet is in protection mode. Ivan |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|