Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Unprotect entire sheet

I have a sheet that is protected so users can enter data is certain cells
without a password. When they do, when and who is tracked on another sheet.
The problem is, I want to be able to enter data in all cells. If I unprotect
the sheet, the code forces me to unprotect the sheet for each cell. Here is
the code I am using:

Private Sub Worksheet_Change(ByVal Target As Range)
Const PW As String = "my password"
ActiveSheet.Unprotect Password:=PW
If firstime = True Then
firstime = False
n = Sheets("changes").Cells(Rows.Count, 1).End(xlUp).Row + 1
Application.EnableEvents = False
Sheets("changes").Cells(n, 1).Value = Now
Sheets("changes").Cells(n, 2).Value = Environ("UserName")
Application.EnableEvents = True
End If
ActiveSheet.Protect Password:=PW
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Unprotect entire sheet

I'm confused. Your code sample doesn't seem to match the problem you are
describing. You are only modifying two cells in your sample code. Are you
saying the sample code you provided doesn't work?

Your description says you are protecting one sheet and tracking information
on another sheet. Which sheet is triggering the Change event? I would
assume the sheet the user changed is triggering the Change event. But,
then, I don't understand the reason for unprotecting it; they've already
made the changes. Is the "changes" sheet also protected?

BTW, why use ActiveSheet when you already have the worksheet pointer; i.e.,
Target.Worksheet. But, again, your description says you are protecting one
sheet and tracking information on another sheet. Which sheet is triggering
the Change event? I would assume the sheet the user changed is triggering
the Change event. But, then, I don't understand the reason for unprotecting
it; they've already made the changes. The problem with using ActiveSheet is
that it could change while your code is running if you ever yield (i.e.
DoEvents).


"Homer" wrote in message
...
I have a sheet that is protected so users can enter data is certain cells
without a password. When they do, when and who is tracked on another
sheet.
The problem is, I want to be able to enter data in all cells. If I
unprotect
the sheet, the code forces me to unprotect the sheet for each cell. Here
is
the code I am using:

Private Sub Worksheet_Change(ByVal Target As Range)
Const PW As String = "my password"
ActiveSheet.Unprotect Password:=PW
If firstime = True Then
firstime = False
n = Sheets("changes").Cells(Rows.Count, 1).End(xlUp).Row + 1
Application.EnableEvents = False
Sheets("changes").Cells(n, 1).Value = Now
Sheets("changes").Cells(n, 2).Value = Environ("UserName")
Application.EnableEvents = True
End If
ActiveSheet.Protect Password:=PW
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
Unprotect the sheet [email protected] Excel Programming 2 May 5th 08 08:01 AM
macro button to unprotect entire workbook (used after password ent klysell Excel Programming 2 August 22nd 07 09:40 PM
unprotect next sheet ADK Excel Programming 6 July 5th 07 03:29 PM
how to Unprotect sheet mangesh Excel Discussion (Misc queries) 1 July 24th 06 10:34 PM
unprotect sheet in code and make sheet visible peach255 Excel Programming 1 August 1st 03 03:28 AM


All times are GMT +1. The time now is 09:47 PM.

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"