Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Changing the value of a protected cell


Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell. How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Changing the value of a protected cell

You must either unlock the cell prior to protecting it, or unprotect
the sheet, change value, and then protect again. There is no other way
around it, or there would be no point to protecting it. If it is a
cell that I dont mind users editing, I unlock it, otherwise I do the
unprotect, change, protect method.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Changing the value of a protected cell

Shawn,
Look at the arguments for the Protect method.
You have an option of UIOnly (or something like that). That means that the
user cannot change the sheet, but code can.

NickHK

"Shawn" ...

Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell.
How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Changing the value of a protected cell

Assuming you don't want to unlock the cell before you protect the sheet, then

Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")
ActiveSheet.Unprotect Password:="ABC"
Range("A1") = goal + 1
Activesheet.Protect Password:="ABC"
End Sub

--
Regards,
Tom Ogilvy



"Shawn" wrote:


Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell. How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Changing the value of a protected cell

UserInterfaceOnly = UIOnly

(just a clarification)

NickHK wrote:

Shawn,
Look at the arguments for the Protect method.
You have an option of UIOnly (or something like that). That means that the
user cannot change the sheet, but code can.

NickHK

"Shawn" ...

Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell.
How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Changing the value of a protected cell

Dave,
Thanks.
I'm currently on a Chinese system without Office installed, so it was
guesswork.

NickHK

"Dave Peterson"
...
UserInterfaceOnly = UIOnly

(just a clarification)

NickHK wrote:

Shawn,
Look at the arguments for the Protect method.
You have an option of UIOnly (or something like that). That means that
the
user cannot change the sheet, but code can.

NickHK

"Shawn"
...

Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell.
How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Changing the value of a protected cell

Wow!

You live in interesting times.

(not meant as a Chinese curse!)

NickHK wrote:

Dave,
Thanks.
I'm currently on a Chinese system without Office installed, so it was
guesswork.

NickHK

"Dave Peterson"
...
UserInterfaceOnly = UIOnly

(just a clarification)

NickHK wrote:

Shawn,
Look at the arguments for the Protect method.
You have an option of UIOnly (or something like that). That means that
the
user cannot change the sheet, but code can.

NickHK

"Shawn"
...

Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell.
How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Changing the value of a protected cell

Dave,
Interesting times for sure, but also Hong Kong, so not surprising really.

NickHK

"Dave Peterson"
...
Wow!

You live in interesting times.

(not meant as a Chinese curse!)

NickHK wrote:

Dave,
Thanks.
I'm currently on a Chinese system without Office installed, so it was
guesswork.

NickHK

"Dave Peterson"
...
UserInterfaceOnly = UIOnly

(just a clarification)

NickHK wrote:

Shawn,
Look at the arguments for the Protect method.
You have an option of UIOnly (or something like that). That means that
the
user cannot change the sheet, but code can.

NickHK

"Shawn"
...

Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected
cell.
How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn

--

Dave Peterson


--

Dave Peterson



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 271
Default Changing the value of a protected cell

I have decided to use sort of a back door method. I am going to make that
cell a formula equal to a value in another sheet that is unprotected.
--
Thanks
Shawn


"Shawn" wrote:


Sub go()
Dim goal As Range
Set goal = Sheets("sheet1").Range("A1")

Range("A1") = goal + 1
End Sub

I get an error because this is on a protected sheet and protected cell. How
can I get result without having to unprotect the sheet?


--
Thanks
Shawn

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
Format changing in protected cell Shaggyjh Excel Discussion (Misc queries) 0 July 31st 09 10:52 AM
Changing Font in an unlocked cell in a protected sheet. Mark T UK Excel Discussion (Misc queries) 2 October 3rd 08 12:03 PM
" / " Changing Decimal number format to Fraction on Protected Cell laudie Excel Worksheet Functions 0 November 15th 05 02:13 AM
" / " Changing Decimal number format to Fraction on Protected Cell laudie Excel Worksheet Functions 0 November 15th 05 01:12 AM
Error changing protected cell Jim Zeeb[_2_] Excel Programming 3 July 4th 05 10:51 PM


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