Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Protect Sheet but enable cell ranges giving Error 1004 Unable to set

Hi,
I am using the following code to disable a worksheet so
that people cannot tamper with data on it as it is used
in formulas else where on the sheet but allow them to
enter data in allocated cells which is then worked on to
give a result. Using the following code gives me an error
1004 Unable to sey the locked property of the Range
Classes , the help file doen't seem to indicate the
reason.

Option Explicit
Sub auto_open()

Worksheets(1).Range("b3:b6").Locked = False 'data
entry cells
Worksheets(1).Range("f6:f8").Locked = False 'change
variables allow cells

Worksheets(1).Protect

Regards

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Protect Sheet but enable cell ranges giving Error 1004 Unable to set

Hi William,

This is an error that I would expect to occur if the worksheet was
already protected when your application started up. Modify your code to
unprotect the worksheet prior to making the changes and the protect it again
afterwards, like so;

Sub auto_open()
Worksheets(1).Unprotect
Worksheets(1).Range("b3:b6").Locked = False 'data entry cells
Worksheets(1).Range("f6:f8").Locked = False 'change variables allow
cells
Worksheets(1).Protect
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"William" wrote in message
...
Hi,
I am using the following code to disable a worksheet so
that people cannot tamper with data on it as it is used
in formulas else where on the sheet but allow them to
enter data in allocated cells which is then worked on to
give a result. Using the following code gives me an error
1004 Unable to sey the locked property of the Range
Classes , the help file doen't seem to indicate the
reason.

Option Explicit
Sub auto_open()

Worksheets(1).Range("b3:b6").Locked = False 'data
entry cells
Worksheets(1).Range("f6:f8").Locked = False 'change
variables allow cells

Worksheets(1).Protect

Regards

End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Protect Sheet but enable cell ranges giving Error 1004 Unable to set

Thanks Gentlemen,
Very Much appreciated.
Regards
William
-----Original Message-----
Hi William,

This is an error that I would expect to occur if the

worksheet was
already protected when your application started up.

Modify your code to
unprotect the worksheet prior to making the changes and

the protect it again
afterwards, like so;

Sub auto_open()
Worksheets(1).Unprotect
Worksheets(1).Range("b3:b6").Locked = False 'data

entry cells
Worksheets(1).Range("f6:f8").Locked = False 'change

variables allow
cells
Worksheets(1).Protect
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"William" wrote in

message
...
Hi,
I am using the following code to disable a worksheet so
that people cannot tamper with data on it as it is used
in formulas else where on the sheet but allow them to
enter data in allocated cells which is then worked on

to
give a result. Using the following code gives me an

error
1004 Unable to sey the locked property of the Range
Classes , the help file doen't seem to indicate the
reason.

Option Explicit
Sub auto_open()

Worksheets(1).Range("b3:b6").Locked = False 'data
entry cells
Worksheets(1).Range("f6:f8").Locked = False 'change
variables allow cells

Worksheets(1).Protect

Regards

End Sub



.

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
Error 1004: Unable to get the axis property Ana via OfficeKB.com Charts and Charting in Excel 1 June 24th 09 11:47 AM
unable to protect cells in macro sheet b/c runtime error 1004 rldjda Excel Worksheet Functions 1 March 20th 08 08:28 PM
Password protect cell ranges NOT sheet Nadia Excel Discussion (Misc queries) 3 December 13th 05 04:57 AM
Run Time Error 1004 Unable to set hidden property Lester Lee Excel Programming 3 July 22nd 04 03:31 AM
Run-time Error '1004' Unable to get the findnext property... Tom Ogilvy Excel Programming 0 July 12th 04 04:27 PM


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