Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Locked Cells?

Row B and C both need to be locked to prevent the user from entering data,
however, I have code that puts a formula into these cells when the user
enters a date into Cell A. When I lock the cells and protect the sheet, I
get an error because the code it trying to add the formula to a locked cell.
Is there any way around this?

Thanks,
Kevin


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Locked Cells?

I assume your are using the on change event... You need to turn protection
off to make your update. Here is some code for you so use as a guideline.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ErrorHandler

Application.EnableEvents = False
If Target.Address = "$A$1" Then
ActiveSheet.Unprotect
'Your other code here...
ActiveSheet.Protect
End If

ErrorHandler:
Application.EnableEvents = True
End Sub

HTH

"Kevin Baker" wrote:

Row B and C both need to be locked to prevent the user from entering data,
however, I have code that puts a formula into these cells when the user
enters a date into Cell A. When I lock the cells and protect the sheet, I
get an error because the code it trying to add the formula to a locked cell.
Is there any way around this?

Thanks,
Kevin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Locked Cells?

Kevin,

Unprotect the sheet first them protect it again after you code.

sheets("test").unportect "Your Password"
'your code
sheets("test").protect "Your Password"

Regards
Neil

"Kevin Baker" wrote in message
news:3cahe.4827$It1.128@lakeread02...
Row B and C both need to be locked to prevent the user from entering data,
however, I have code that puts a formula into these cells when the user
enters a date into Cell A. When I lock the cells and protect the sheet, I
get an error because the code it trying to add the formula to a locked
cell. Is there any way around this?

Thanks,
Kevin



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
Locked worksheet & hyperlinks (w/ select locked cells unchecked) dgold82 Excel Discussion (Misc queries) 1 July 10th 09 09:42 PM
paste locked cells and unlocked cells in protected sheet Angeline Excel Worksheet Functions 15 November 1st 06 11:51 PM
Put comments on a locked spreadsheet even though cells not locked RDP Excel Worksheet Functions 1 September 11th 05 11:59 PM
Delete specific cells contents in a row with some locked cells in the same row trussman Excel Programming 2 March 1st 05 06:12 PM
I want the macros to be locked up when cells are locked up. Ed Excel Programming 6 February 20th 05 01:31 AM


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