![]() |
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 |
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 |
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 |
All times are GMT +1. The time now is 04:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com