Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi,
I have the following macro written in spreadsheets to protect them, however, in some workbooks there are 12 month tabs & a 'workings' tab. in the workings tab i require different functionality (e.g. inserting rows & columns) than the 12 month tabs. How do i change the macro to reflect this? Sub ProtectAll() Dim sPassword As String sPassword = "LMW5487" If Application.InputBox( _ Prompt:="Please enter the password", _ Title:="Password", _ Type:=2) < sPassword Then MsgBox "Wrong password!" Exit Sub End If Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets ws.Protect Password:="LMW5487", DrawingObjects:=False, Contents:=True, Scenarios:= _ True, AllowFormattingCells:=True, AllowSorting:=True, AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, AllowFiltering:= _ True, AllowFormattingColumns:=True Next ws End Sub -- Lois |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi Lois,
According to your code, inserting & deleting rows is already allowed. Presumably you want the 'workings' sheet to allow inserting & deleting columns also. In that case: Sub ProtectAll() Dim sPassword As String sPassword = "LMW5487" If Application.InputBox(Prompt:="Please enter the password", Title:="Password", _ Type:=2) < sPassword Then MsgBox "Wrong password!" End End If Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.Name < "workings" Then ws.Protect Password:="sPassword", DrawingObjects:=False, Contents:=True, _ Scenarios:=True, AllowFormattingCells:=True, AllowSorting:=True, _ AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, _ AllowFiltering:=True, AllowFormattingColumns:=True Else ws.Protect Password:="sPassword", DrawingObjects:=False, Contents:=True, _ Scenarios:=True, AllowFormattingCells:=True, AllowSorting:=True, _ AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, _ AllowFiltering:=True, AllowFormattingColumns:=True, AllowInsertingColumns:=True, _ AllowDeletingColumns:=True End If Next ws End Sub where 'workings' is the name of the worksheet to leave unprotected -- Cheers macropod [Microsoft MVP - Word] "Lois" wrote in message ... Hi, I have the following macro written in spreadsheets to protect them, however, in some workbooks there are 12 month tabs & a 'workings' tab. in the workings tab i require different functionality (e.g. inserting rows & columns) than the 12 month tabs. How do i change the macro to reflect this? Sub ProtectAll() Dim sPassword As String sPassword = "LMW5487" If Application.InputBox( _ Prompt:="Please enter the password", _ Title:="Password", _ Type:=2) < sPassword Then MsgBox "Wrong password!" Exit Sub End If Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets ws.Protect Password:="LMW5487", DrawingObjects:=False, Contents:=True, Scenarios:= _ True, AllowFormattingCells:=True, AllowSorting:=True, AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, AllowFiltering:= _ True, AllowFormattingColumns:=True Next ws End Sub -- Lois |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
great thanks
-- Lois "macropod" wrote: Hi Lois, According to your code, inserting & deleting rows is already allowed. Presumably you want the 'workings' sheet to allow inserting & deleting columns also. In that case: Sub ProtectAll() Dim sPassword As String sPassword = "LMW5487" If Application.InputBox(Prompt:="Please enter the password", Title:="Password", _ Type:=2) < sPassword Then MsgBox "Wrong password!" End End If Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets If ws.Name < "workings" Then ws.Protect Password:="sPassword", DrawingObjects:=False, Contents:=True, _ Scenarios:=True, AllowFormattingCells:=True, AllowSorting:=True, _ AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, _ AllowFiltering:=True, AllowFormattingColumns:=True Else ws.Protect Password:="sPassword", DrawingObjects:=False, Contents:=True, _ Scenarios:=True, AllowFormattingCells:=True, AllowSorting:=True, _ AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, _ AllowFiltering:=True, AllowFormattingColumns:=True, AllowInsertingColumns:=True, _ AllowDeletingColumns:=True End If Next ws End Sub where 'workings' is the name of the worksheet to leave unprotected -- Cheers macropod [Microsoft MVP - Word] "Lois" wrote in message ... Hi, I have the following macro written in spreadsheets to protect them, however, in some workbooks there are 12 month tabs & a 'workings' tab. in the workings tab i require different functionality (e.g. inserting rows & columns) than the 12 month tabs. How do i change the macro to reflect this? Sub ProtectAll() Dim sPassword As String sPassword = "LMW5487" If Application.InputBox( _ Prompt:="Please enter the password", _ Title:="Password", _ Type:=2) < sPassword Then MsgBox "Wrong password!" Exit Sub End If Dim ws As Worksheet For Each ws In ActiveWorkbook.Worksheets ws.Protect Password:="LMW5487", DrawingObjects:=False, Contents:=True, Scenarios:= _ True, AllowFormattingCells:=True, AllowSorting:=True, AllowDeletingRows:=True, AllowInsertingRows:=True, AllowFormattingRows:=True, AllowFiltering:= _ True, AllowFormattingColumns:=True Next ws End Sub -- Lois |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro protection | Excel Worksheet Functions | |||
macro protection | Excel Discussion (Misc queries) | |||
Protection macro | Excel Discussion (Misc queries) | |||
Macro and row protection | Excel Discussion (Misc queries) | |||
macro for protection | Excel Discussion (Misc queries) |