Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rk Rk is offline
external usenet poster
 
Posts: 18
Default Excel Protect Function, while allowing macros

How can I protect a range of cells, so that Macros will work in those cells,
but users cannot access them?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 269
Default Excel Protect Function, while allowing macros

Lock the cells and protect the worksheet. Have the macro unprotect the sheet
and then reprotect it when done.

ActiveSheet.Unprotect Password:="mypassword"
'Do Stuff
ActiveSheet.Protect Password:="mypassword"

There are a lot of potential options for protection so I would recommend
that you use the marco recorder to record you sheet protection to get all of
the conditions.

NOTE: The recorder will not record the password, you need to add this
section manually

This is a sample of what you may get
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True, AllowFormattingColumns:=True,
AllowFormattingRows:=True

Simply add the condition Password:="mypassword" like this

ActiveSheet.Protect Password:="mypassword",DrawingObjects:=False,
Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True, AllowFormattingColumns:=True,
AllowFormattingRows:=True


--
If this helps, please remember to click yes.


"RK" wrote:

How can I protect a range of cells, so that Macros will work in those cells,
but users cannot access them?

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22
Default Excel Protect Function, while allowing macros

Of course if you put the password in the code, anyone can read it if the open
the visual basic editor...

to protect against this you old protect the VBproject, from the editor
window select menu ToolsVBAProject Properties... select the Protection tab
and then check the lock option and enter a password, and remember to keep it
in a secure place!

Next time the file is opened your code will be protected.

--
If this is the answer you hoped for please remember to click the yes button
below...

Kind regards

Rik


"Paul C" wrote:

Lock the cells and protect the worksheet. Have the macro unprotect the sheet
and then reprotect it when done.

ActiveSheet.Unprotect Password:="mypassword"
'Do Stuff
ActiveSheet.Protect Password:="mypassword"

There are a lot of potential options for protection so I would recommend
that you use the marco recorder to record you sheet protection to get all of
the conditions.

NOTE: The recorder will not record the password, you need to add this
section manually

This is a sample of what you may get
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True, AllowFormattingColumns:=True,
AllowFormattingRows:=True

Simply add the condition Password:="mypassword" like this

ActiveSheet.Protect Password:="mypassword",DrawingObjects:=False,
Contents:=True, Scenarios:= _
True, AllowFormattingCells:=True, AllowFormattingColumns:=True,
AllowFormattingRows:=True


--
If this helps, please remember to click yes.


"RK" wrote:

How can I protect a range of cells, so that Macros will work in those cells,
but users cannot access them?

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
Allowing Macros and Links in Excel 2007 Marilyn Excel Discussion (Misc queries) 0 December 10th 08 07:16 PM
How do I protect a number of sheets allowing the user to add a com Prashanth KR New Users to Excel 8 August 28th 07 04:06 PM
To Protect Excel documents and allowing only few cells to edit DHANRAJ Excel Worksheet Functions 1 March 29th 06 03:18 PM
How can I lock worksheets while still allowing macros to operate? enginguven Excel Discussion (Misc queries) 1 January 9th 06 09:47 PM
Allowing Macros in Excel Trevor Setting up and Configuration of Excel 1 February 18th 05 10:48 PM


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

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"