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: 553
Default Accidentally Protecting Sheets

I have a macro which checks to see if any of my worksheets are protected
prior to running a larger macro. It has been flagging protected sheets that
I am not knowingly protecting.

I set up a Watch using the line: Cell.Parent.Protect = True.

It breaks on the first line of the Public Function. I have stepped through
it and it seems to protect the sheet on the line:

ElseIf CellIsHidden(Cell) And ProtectedCellsChkBx = False Then.

Why is this happening with the IF argument? Everytime I run this I have to
unprotect my sheets. What even odder is that in my immedaite window I have
typed in the same term as used for my watch (?Cell.Parent.Protect = True),
and it equals TRUE on the line:

SummarySheetRowCounter =
Application.WorksheetFunction.CountBlank(Worksheet s(AuditShtName).Range("B2:B65536").Offset(0, AuditTypes * 2 - 2))

So I don't why this happening and I don't know why my tests are showing it
happening in the places its happening in!

Thanks

For Each sh In ActiveWorkbook.Worksheets
For AuditTypes = 1 To ChkbxArraySum
For Each Cell In sh.UsedRange
SummarySheetRowCounter =
Application.WorksheetFunction.CountBlank(Worksheet s(AuditShtName).Range("B2:B65536").Offset(0, AuditTypes * 2 - 2))
If SummarySheetRowCounter = 1 Then Exit For
'On Error Resume Next
If MainUserForm.IgnoreBlanksBttn = True And _
IsEmpty(Cell) Then
'do nothing and let loop advance to next
'cell in UsedRange
ElseIf CellIsHidden(Cell) And ProtectedCellsChkBx = False Then
'Do nothing
Else
'Do something
End If
Next
Next
Next

Public Function CellIsHidden(Cell As Range)
If Cell.Parent.Protect = True Then
If Cell.FormulaHidden = True Then
CellIsHidden = True
End If
End If
End Function
 
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
protecting sheets christina Excel Discussion (Misc queries) 2 May 29th 09 11:27 PM
Help w/ protecting all sheets cnote Excel Discussion (Misc queries) 6 June 27th 06 01:38 PM
Protecting sheets TV Excel Discussion (Misc queries) 1 November 29th 04 09:27 PM
Protecting buttons with VB code rather than protecting sheets/books? StargateFanFromWork Excel Programming 2 July 16th 04 04:03 PM
Protecting sheets LC[_5_] Excel Programming 1 February 19th 04 05:14 AM


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