Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Visually check Protection code

I wish to check that a complicated (for me) protection routine is
coded and operating correctly.

Addin code allows a User to select their workbook(s) and then
continues to open their selection. As it does so, code ends with
.Protect
.EnableSelection = xlUnlockedCells

Can I say something like:

Sub Test_Protection()
Dim ws As Worksheet, c As Range
For Each ws In ActiveWorkbook.Worksheets
With ws
For Each c In .UsedRange.Columns("A:G")
If Not c.Locked = True Then
'User is permitted to edit this cell, so color it:
c.Interior.ColorIndex = 34
End If
Next
End With
Next
End Sub

This doesn't work for me.

Regards.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Visually check Protection code

if you unprotect the worksheet it should work.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I wish to check that a complicated (for me) protection routine is
coded and operating correctly.

Addin code allows a User to select their workbook(s) and then
continues to open their selection. As it does so, code ends with
.Protect
.EnableSelection = xlUnlockedCells

Can I say something like:

Sub Test_Protection()
Dim ws As Worksheet, c As Range
For Each ws In ActiveWorkbook.Worksheets
With ws
For Each c In .UsedRange.Columns("A:G")
If Not c.Locked = True Then
'User is permitted to edit this cell, so color it:
c.Interior.ColorIndex = 34
End If
Next
End With
Next
End Sub

This doesn't work for me.

Regards.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Visually check Protection code

Thanks, but I had tried that. It unprotected the sheet
but my code failed to change the cell's colour.

Setting up cell "B45" and running this amended code
seems to work:
Sub Test_Protection2()
Dim ws As Worksheet, c As Range
For Each ws In ActiveWorkbook.Worksheets
With ws
.Unprotect
' For Each c In .UsedRange.Columns("A:G")
' If Not c.Locked = True Then
' 'User is permitted to edit this cell, so color it:
' c.Interior.ColorIndex = 34
' End If
' Next
If Not .Range("B45").Locked = True Then
.Range("B45").Interior.ColorIndex = 34
End If
End With
Next
End Sub

Now why might this work, but not the first version, please?

Regards.

"Tom Ogilvy" wrote in message
...
if you unprotect the worksheet it should work.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I wish to check that a complicated (for me) protection routine is
coded and operating correctly.

Addin code allows a User to select their workbook(s) and then
continues to open their selection. As it does so, code ends with
.Protect
.EnableSelection = xlUnlockedCells

Can I say something like:

Sub Test_Protection()
Dim ws As Worksheet, c As Range
For Each ws In ActiveWorkbook.Worksheets
With ws
For Each c In .UsedRange.Columns("A:G")
If Not c.Locked = True Then
'User is permitted to edit this cell, so color it:
c.Interior.ColorIndex = 34
End If
Next
End With
Next
End Sub

This doesn't work for me.

Regards.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Visually check Protection code

Apologies, because I think the error lies in the original
"protection" routine. I had been trying to avoid selecting
each worksheet before applying the "protection" code.
Looks as though avoiding 'select' results in the code
failing to protect the sheet.

Regards.

"Tom Ogilvy" wrote in message
...
if you unprotect the worksheet it should work.

--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I wish to check that a complicated (for me) protection routine is
coded and operating correctly.

Addin code allows a User to select their workbook(s) and then
continues to open their selection. As it does so, code ends with
.Protect
.EnableSelection = xlUnlockedCells

Can I say something like:

Sub Test_Protection()
Dim ws As Worksheet, c As Range
For Each ws In ActiveWorkbook.Worksheets
With ws
For Each c In .UsedRange.Columns("A:G")
If Not c.Locked = True Then
'User is permitted to edit this cell, so color it:
c.Interior.ColorIndex = 34
End If
Next
End With
Next
End Sub

This doesn't work for me.

Regards.




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.692 / Virus Database: 453 - Release Date: 28/05/2004


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
Protection and Spell check ochoaex Excel Worksheet Functions 0 February 3rd 06 03:45 PM
Spell check and protection Mici Excel Discussion (Misc queries) 1 January 14th 06 04:07 AM
Protection of check boxes in excel 2002 Newbeetle Excel Discussion (Misc queries) 2 March 14th 05 12:59 PM
Spell Check w/ Protection Peter Excel Discussion (Misc queries) 3 December 29th 04 09:28 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


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