LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Unprotected sheet is protected?

The following code clears the raw data out of the data entry worksheets in
the workbook. Here is the macro:

Private Sub ClearAllData()
Dim ws As Worksheet
Dim rRangeStart As Range
Dim rRangeErase As Range
Dim lRow As Long
Dim wsSheet1 As Worksheet
Dim sPWORD As String

Application.EnableEvents = False
Set wsSheet1 = ThisWorkbook.Worksheets("Sheet1")

For Each ws In ThisWorkbook.Worksheets
If ws.Name < "Totals" Then
wsSheet1.Visible = True

wsSheet1.Range("D2") = ws.Name
sPWORD = wsSheet1.Range("D1")
With ws
.Unprotect Password:=sPWORD
End With
Set rRangeStart = Range("A8")

With ws.Range("A7").CurrentRegion
lRow = .Rows(.Rows.Count).Row
End With

Set rRangeErase = Range(rRangeStart, Cells(lRow, "P"))
rRangeErase.ClearContents <------ THE CELL OR CHART YOU ARE TRYING TO
CHANGE IS PROTECTED AND THEREFORE READ-ONLY
With ws
.Protect Password:=sPWORD
End With
End If
Next ws

wsSheet1.Visible = False
Application.EnableEvents = True
End Sub

The problem is that the "protection" is not XL protection, but created by
an event driven macro. When the user attempts to enter data, s/he is
prompted for the password for that particular sheet. The passwords are
stored in a normally hidden sheet ("Sheet1"). I thought that by turning off
EnableEvents, the sheet protection macro would no longer be triggered and I
could edit these sheets. Why is this not so? Is there an easy fix?
 
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
Unable to highlight an unprotected cell on a protected sheet. Del[_2_] Excel Worksheet Functions 1 September 4th 08 02:04 PM
Adding comments to unprotected cell in a protected sheet Dave Excel Discussion (Misc queries) 3 February 8th 06 10:59 PM
Allow unprotected cells to spell check after sheet is protected Numberonekraut (Hans) Excel Worksheet Functions 1 September 15th 05 07:55 PM
TAB and focus moving from unprotected cell in protected sheet til dropdown. Claus[_3_] Excel Programming 0 August 26th 05 11:28 AM
Tab key don't work in unprotected cells in a protected sheet Chad Excel Discussion (Misc queries) 0 August 16th 05 02:00 AM


All times are GMT +1. The time now is 02:56 PM.

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"