Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Over protection in 2002 XP environment

Since you're changing multiple cells, maybe you should unprotect the worksheet
before doing this:

For intCounter = -6 To -3
objActiveCell.Offset(0, intCounter).Value = ""
Next intCounter

And you may want to change ActiveCell to Target (or just use Target directly).
Target is the cell you just changed.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Dim intCounter As Long

On Error GoTo errHandler:

Select Case Target.Value
Case "A", "B"
Application.EnableEvents = False
Me.Unprotect Password:="drowssap"

For intCounter = -6 To -3
Target.Offset(0, intCounter).Value = ""
Next intCounter

Target.Offset(0, -2).Value = 0

Me.Protect Password:="drowssap"
Application.EnableEvents = True

End Select

errHandler:
Application.EnableEvents = True

End Sub

The .enableevents stuff stops the code from being called when you change one of
the cells.


Michael wrote:

Hi
How can you protect and unprotect sheets in code in Excel
2002 where cell values are selected from a validated list.

In Excel 2000 SP3 this code works
Private Sub Worksheet_Change(ByVal Target As Range)
...
...
Select Case Target.Value
Case "A", "B"
Set objActiveCell = ActiveCell
For intCounter = -6 To -3
objActiveCell.Offset(0, intCounter).Value = ""
Next intCounter
ActiveSheet.Unprotect Password:="drowssap"
objActiveCell.Offset(0, -2).Value = 0
ActiveSheet.Protect Password:="drowssap"
Case ....

On the test install Excel 2002 break points suggest sheet
protection is detected and the change event is not executed

Many Thanks
Michael


--

Dave Peterson

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
Problems with cell protection-Excel 2002 SP3 -charles- Excel Discussion (Misc queries) 0 July 21st 09 01:56 AM
what is ERP environment Rao Ratan Singh New Users to Excel 1 April 18th 06 03:16 PM
Protection of check boxes in excel 2002 Newbeetle Excel Discussion (Misc queries) 2 March 14th 05 12:59 PM
Excel 2002 Pivot Table Protection Kirk P. Excel Discussion (Misc queries) 1 February 23rd 05 10:08 PM
Excel 2002 VBA App fails in Excel 2000 Environment Steve Bunker Excel Programming 2 September 10th 03 01:04 PM


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