Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Verify protection status within a macro
I have a sheet that is kept protected unless it is time for data entry. I
would like to run a macro that checks for protection status, unprotect if needed, then sorts, then returns the sheet to the protection status (i.e. if not protected, leave unprotected, if protected, reprotect). Help? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Verify protection status within a macro
Maybe...
Option Explicit Sub testme01() Dim WasProtected as Boolean wasprotected = WksIsProtected(Worksheets("sheet1")) if wasprotected = true then 'unprotect the sheet end if 'do your sort if wasprotected = true then 'reprotect the sheet end if End Sub Function WksIsProtected(wks As Worksheet) As Boolean If wks.ProtectContents = True _ Or wks.ProtectDrawingObjects = True _ Or wks.ProtectScenarios = True Then WksIsProtected = True Else WksIsProtected = False End If End Function Pivot Table/Query wrote: I have a sheet that is kept protected unless it is time for data entry. I would like to run a macro that checks for protection status, unprotect if needed, then sorts, then returns the sheet to the protection status (i.e. if not protected, leave unprotected, if protected, reprotect). Help? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Determining a worksheet's protection status in VBA | Excel Discussion (Misc queries) | |||
Worksheet Protection status | Excel Worksheet Functions | |||
Worksheet protection status | Excel Discussion (Misc queries) | |||
Display worksheet protection status in a cell? | Excel Worksheet Functions | |||
Sheet Protection Status | Excel Worksheet Functions |