Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determining a worksheet's protection status in VBA GeorgeJ Excel Discussion (Misc queries) 2 August 4th 07 12:26 AM
Worksheet Protection status JimB Excel Worksheet Functions 1 September 28th 06 11:02 PM
Worksheet protection status JimB Excel Discussion (Misc queries) 0 September 28th 06 10:03 PM
Display worksheet protection status in a cell? Geoff C Excel Worksheet Functions 2 February 1st 06 03:04 PM
Sheet Protection Status Andy Williams Excel Worksheet Functions 1 January 4th 06 04:22 PM


All times are GMT +1. The time now is 04:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"