PC Review


Reply
Thread Tools Rate Thread

Controlling worksheet protection via VBA

 
 
New Member
Join Date: Jun 2010
Posts: 2
 
      1st Jun 2010
I have created a user form with VBA for data entry in an Excel worksheet. I would like to control what the user can modify and so have protected the cells.

After filling out the form I would like my VBA code to return the worksheet to its previously protected state.

I have tried to control the password protection on my worksheet via VBA using the following code:

Public Sub Protect()
Worksheets("myWorksheet").Protect Password:="password", _
UserInterfaceOnly:=True
End Sub


Public Sub UnProtect()
Worksheets("myWorksheet").UnProtect Password:="password"
End Sub


This works okay in that it reprotects the sheet, the only problem is that the level of protection is too high. I had previously allowed formatting of columns, rows and cells but now the sheet is completely locked.

Is there any way to pass an argument into this protect subroutine so that I can control the level of protection?

Thanks
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel- Controlling worksheet protection via VBA Áine Webmaster / Programming 1 1st Sep 2010 01:15 AM
Cell Protection vs. Worksheet Protection =?Utf-8?B?a213aGl0dA==?= Microsoft Excel Misc 4 24th Sep 2006 02:37 AM
Worksheet protection is gone and only wokbook protection can be se =?Utf-8?B?RXJpYyBDLg==?= Microsoft Excel Misc 4 2nd May 2006 04:50 PM
Controlling text in an Excel worksheet =?Utf-8?B?c3ByaWNl?= Microsoft Excel Worksheet Functions 1 10th Sep 2005 12:41 AM
Controlling a cell in a worksheet Michael Singmin Microsoft Excel Programming 5 3rd Jul 2004 08:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 AM.