Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Protecting sheet through vba while allowing some actions

Hi,

I've done a lot of searching on this but am stuck - I'm guessing the answer
is simple - basically, I have a large file with 65 sheets -- on 15 of these
sheets, I would like to have them protected, but still allow the user to do
things such as sort, autofilter, format, and a few others.

The issue is that there is a lot of code that needs to be executed on these
sheets when certain buttons are clicked, so I would like to protect the
userinterface only. From what I have found, this can be done using code like
the following - my issue is that I need to allow the user to do more than
what is listed below -- is there a complete list of "Enables" (for lack of a
better term") that can be used? IE - I need to allow the users to "Format
Cells", "Format Columns", and "Edit Objects" -- these are all choices in the
protection pop-up menu when manually setting protection.

I guess the question is how can I set these same parameters using vba?

With Worksheets("Sheet1")
.Enable.Sort
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With


--
Robert
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protecting sheet through vba while allowing some actions

Type "worksheet" (without quote marks)(note there's NO "s" at the end) in a
code window or the Immediate window and, with the text cursor touching the
word anywhere, press F1. When the dialog box appears, pick the first item in
the list... Worksheet (object). That will take you to the help files for the
"Worksheet Object". The available Properties, Methods and Events will be
available via the links at the top of the page.

Rick


"robs3131" wrote in message
...
Hi,

I've done a lot of searching on this but am stuck - I'm guessing the
answer
is simple - basically, I have a large file with 65 sheets -- on 15 of
these
sheets, I would like to have them protected, but still allow the user to
do
things such as sort, autofilter, format, and a few others.

The issue is that there is a lot of code that needs to be executed on
these
sheets when certain buttons are clicked, so I would like to protect the
userinterface only. From what I have found, this can be done using code
like
the following - my issue is that I need to allow the user to do more than
what is listed below -- is there a complete list of "Enables" (for lack of
a
better term") that can be used? IE - I need to allow the users to "Format
Cells", "Format Columns", and "Edit Objects" -- these are all choices in
the
protection pop-up menu when manually setting protection.

I guess the question is how can I set these same parameters using vba?

With Worksheets("Sheet1")
.Enable.Sort
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With


--
Robert


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Protecting sheet through vba while allowing some actions

Thanks Rick. After looking around in Help for a while, I finally found what
felt like to be the "holy grail" of information I was looking for - all
parameters that can be set when using "Activesheet.protect" For anyone else
looking for this, after getting to "Worksheet Object" in help (as Rick
explains below), follow this path: Worksheet Object - Methods - Protect -
Worksheet Object.

Now the question I have is that it looks like "AllowSorting:=True" only
works if the cells trying to be sorted are unlocked or unprotected...is there
a way to sort protected cells?

Thanks!

--
Robert


"Rick Rothstein (MVP - VB)" wrote:

Type "worksheet" (without quote marks)(note there's NO "s" at the end) in a
code window or the Immediate window and, with the text cursor touching the
word anywhere, press F1. When the dialog box appears, pick the first item in
the list... Worksheet (object). That will take you to the help files for the
"Worksheet Object". The available Properties, Methods and Events will be
available via the links at the top of the page.

Rick


"robs3131" wrote in message
...
Hi,

I've done a lot of searching on this but am stuck - I'm guessing the
answer
is simple - basically, I have a large file with 65 sheets -- on 15 of
these
sheets, I would like to have them protected, but still allow the user to
do
things such as sort, autofilter, format, and a few others.

The issue is that there is a lot of code that needs to be executed on
these
sheets when certain buttons are clicked, so I would like to protect the
userinterface only. From what I have found, this can be done using code
like
the following - my issue is that I need to allow the user to do more than
what is listed below -- is there a complete list of "Enables" (for lack of
a
better term") that can be used? IE - I need to allow the users to "Format
Cells", "Format Columns", and "Edit Objects" -- these are all choices in
the
protection pop-up menu when manually setting protection.

I guess the question is how can I set these same parameters using vba?

With Worksheets("Sheet1")
.Enable.Sort
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With


--
Robert



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protecting sheet through vba while allowing some actions

You can execute Unprotect method of the worksheet in question beforehand and
execute Protect method afterwards. However, you should look the Protect
method up in the help files as there are several optional arguments
available. Also, if there is a password, you will have to know what it is.

Rick


"robs3131" wrote in message
...
Thanks Rick. After looking around in Help for a while, I finally found
what
felt like to be the "holy grail" of information I was looking for - all
parameters that can be set when using "Activesheet.protect" For anyone
else
looking for this, after getting to "Worksheet Object" in help (as Rick
explains below), follow this path: Worksheet Object - Methods - Protect -
Worksheet Object.

Now the question I have is that it looks like "AllowSorting:=True" only
works if the cells trying to be sorted are unlocked or unprotected...is
there
a way to sort protected cells?

Thanks!

--
Robert


"Rick Rothstein (MVP - VB)" wrote:

Type "worksheet" (without quote marks)(note there's NO "s" at the end) in
a
code window or the Immediate window and, with the text cursor touching
the
word anywhere, press F1. When the dialog box appears, pick the first item
in
the list... Worksheet (object). That will take you to the help files for
the
"Worksheet Object". The available Properties, Methods and Events will be
available via the links at the top of the page.

Rick


"robs3131" wrote in message
...
Hi,

I've done a lot of searching on this but am stuck - I'm guessing the
answer
is simple - basically, I have a large file with 65 sheets -- on 15 of
these
sheets, I would like to have them protected, but still allow the user
to
do
things such as sort, autofilter, format, and a few others.

The issue is that there is a lot of code that needs to be executed on
these
sheets when certain buttons are clicked, so I would like to protect the
userinterface only. From what I have found, this can be done using
code
like
the following - my issue is that I need to allow the user to do more
than
what is listed below -- is there a complete list of "Enables" (for lack
of
a
better term") that can be used? IE - I need to allow the users to
"Format
Cells", "Format Columns", and "Edit Objects" -- these are all choices
in
the
protection pop-up menu when manually setting protection.

I guess the question is how can I set these same parameters using vba?

With Worksheets("Sheet1")
.Enable.Sort
.EnableAutoFilter = True
.Protect UserInterfaceOnly:=True
End With


--
Robert




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
protecting a sheet yet allowing for sorting, filtering, formatting [email protected] Excel Discussion (Misc queries) 0 June 28th 06 03:39 PM
Protecting Sheet and still allowing for sorting, filtering and formatting [email protected] Excel Discussion (Misc queries) 0 June 26th 06 05:19 PM
protecting cells against editing by copy/paste actions grigoras victor Excel Discussion (Misc queries) 0 June 20th 06 10:37 AM
protecting cells against editing by copy/paste actions grigoras victor Setting up and Configuration of Excel 0 June 20th 06 10:37 AM
protecting cells against editing by copy/paste actions grigoras victor Excel Programming 0 June 20th 06 10:37 AM


All times are GMT +1. The time now is 07:15 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"