Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Return boolean if sheet is currently protected

I want to Create a simple Sub that protects the sheet if it is not currently
protected, and unprotects the sheet if it is protected...
i.e.
Sub SheetProtect ()
If ActiveSheet.Protect = true then
ActiveSheet.Unprotect
Else
ActiveSheet.Protect
End If
End Sub

The part that I need help with is obviously the "If" argument.

Any help would be appreciative.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Return boolean if sheet is currently protected

Hi Mike,

Try this

With ActiveSheet
If Not .ProtectContents Then
.Protect
Else
.Unprotect
End If
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I want to Create a simple Sub that protects the sheet if it is not

currently
protected, and unprotects the sheet if it is protected...
i.e.
Sub SheetProtect ()
If ActiveSheet.Protect = true then
ActiveSheet.Unprotect
Else
ActiveSheet.Protect
End If
End Sub

The part that I need help with is obviously the "If" argument.

Any help would be appreciative.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Return boolean if sheet is currently protected

Thanks much.

"Bob Phillips" wrote:

Hi Mike,

Try this

With ActiveSheet
If Not .ProtectContents Then
.Protect
Else
.Unprotect
End If
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I want to Create a simple Sub that protects the sheet if it is not

currently
protected, and unprotects the sheet if it is protected...
i.e.
Sub SheetProtect ()
If ActiveSheet.Protect = true then
ActiveSheet.Unprotect
Else
ActiveSheet.Protect
End If
End Sub

The part that I need help with is obviously the "If" argument.

Any help would be appreciative.




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
lookup single value in one sheet, return multiple results from theother sheet Chuck[_3_] Excel Worksheet Functions 1 April 4th 08 06:17 AM
Protected sheet disables return key. GARDNERGUY Excel Discussion (Misc queries) 0 April 20th 07 08:14 PM
using array, Match, trying to eliminate duplicates - how to return or translate result to a boolean? KR Excel Programming 4 April 4th 05 09:18 PM
Return to Current Sheet in On (sheet activate) event macro Paul Moles Excel Programming 1 March 27th 05 03:16 PM
excel - macro code to open a protected sheet, enter passowrd, and then protect sheet arunjoshi[_5_] Excel Programming 1 May 2nd 04 03:50 PM


All times are GMT +1. The time now is 10:45 PM.

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"