Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell protection problem
Private Sub LockWorkBook()
Dim wrkSheetTot As Integer Dim i As Integer wrkSheetTot = ActiveWorkbook.Worksheets.Count Sheets("Banking").Select Activesheet.UnProtect "TEST" Range("H4:H6").Select Selection.Locked = False For i = 1 To wrkSheetTot ActiveWorkbook.Worksheets(i).Select ActiveSheet.Protect "TEST", DrawingObjects:=True, Contents:=True, Scenarios:=True Next ActiveWorkbook.Worksheets("Banking").Select ActiveWorkbook.Worksheets("IncomeData").Visible = False ActiveWorkbook.Worksheets("BankingData").Visible = False ActiveWorkbook.Worksheets("TelephoneNos").Visible = False ActiveWorkbook.Protect "TEST", Structu=True, Windows:=False End Sub -- Regards, Tom Ogilvy "Alastair MacFarlane" wrote in message ... Dear All, I am trying to create a procedure that: (a) Create an area on a sheet "Banking" that users can enter values where the remainder of the spreadsheet is locked. (b) Loops round all the sheets in the workbook and locks them. (c) Hides the worksheets with the exception of the sheet "Banking". (d) Protects the workbook. The problem I am having is that I get the message "The cell you are trying to change is protected and therefore read only". I cannot identify the cause of this message. I have tried setting Application.DisplayAlerts = False to stop the message or Break On All Errors, but with no luck. Can anyone help me? After I click on the error message the workbook is set up the way I want it but I don’t want to see this message. Private Sub LockWorkBook() Dim wrkSheetTot As Integer Dim i As Integer wrkSheetTot = ActiveWorkbook.Worksheets.Count Sheets("Banking").Select Range("H4:H6").Select Selection.Locked = False For i = 1 To wrkSheetTot ActiveWorkbook.Worksheets(i).Select ActiveSheet.Protect "TEST", DrawingObjects:=True, Contents:=True, Scenarios:=True Next ActiveWorkbook.Worksheets("Banking").Select ActiveWorkbook.Worksheets("IncomeData").Visible = False ActiveWorkbook.Worksheets("BankingData").Visible = False ActiveWorkbook.Worksheets("TelephoneNos").Visible = False ActiveWorkbook.Protect "TEST", Structu=True, Windows:=False End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Problem with protection of cells | Excel Discussion (Misc queries) | |||
Protection Problem Using A Network | Excel Discussion (Misc queries) | |||
Cell Protection vs. Worksheet Protection | Excel Discussion (Misc queries) | |||
VB Protection problem | Excel Worksheet Functions | |||
Protection Problem | Excel Discussion (Misc queries) |