Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default protect sheet

I need to password protect the worksheet when the userform is closed and
unprotect it when the userform is open. Can anyone help me???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default protect sheet


enyaw wrote:
I need to password protect the worksheet when the userform is closed and
unprotect it when the userform is open. Can anyone help me???


How about....

Call ProtectSheet(False, "Sheet1")
frmUserForm.Show 1
... do whatever provessing the form requires ...
Call ProtectSheet(True, "Sheet1")

Private Sub ProtectSheet(bProtect As Boolean, sSheet As String)

If bProtect Then
Worksheets(sSheet).Protect Password:="<your password",
AllowFiltering:=True
Else
Worksheets(sSheet).Unprotect ("<your password")
End If

End Sub



I use a string variable to hold the password, and ProtectSheet because
I can use it for different worksheets, but you can just as easily use
just the code within the IF statement if you wish.


HTH

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default protect sheet


enyaw wrote:
I need to password protect the worksheet when the userform is closed and
unprotect it when the userform is open. Can anyone help me???


How about....

Call ProtectSheet(False, "Sheet1")
frmUserForm.Show 1
... do whatever provessing the form requires ...
Call ProtectSheet(True, "Sheet1")

Private Sub ProtectSheet(bProtect As Boolean, sSheet As String)

If bProtect Then
Worksheets(sSheet).Protect Password:="<your password",
AllowFiltering:=True
Else
Worksheets(sSheet).Unprotect ("<your password")
End If

End Sub



I use a string variable to hold the password, and ProtectSheet because
I can use it for different worksheets, but you can just as easily use
just the code within the IF statement if you wish.


HTH

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
Protect Workbook Vs Protect Sheet Poor_pakistani New Users to Excel 4 May 25th 06 02:06 PM
Can I protect columns w/in a "List" using Protect Sheet? Diane Excel Discussion (Misc queries) 0 May 10th 06 03:30 PM
Lock and protect cells without protect the sheet Christian[_7_] Excel Programming 6 December 28th 04 04:50 PM
Protect the sheet Sambusa[_11_] Excel Programming 0 October 6th 04 04:04 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 11:43 PM.

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

About Us

"It's about Microsoft Excel"