Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Protect/Unprotect Sheet from Macro

Hi All
I have a worksheet that in large part has locked cells, the sheet is then
protected. This of course disables sort. What I am trying to do is
unprotect the sheet, do the sort and then protect the sheet. I have not as
yet added a password.

If I do the above manually from the UI, all is OK, but the macro that
follows fails on the sort method. The sheet is showing unprotected. Problem
in both xl97 and xl2002.

ActiveSheet.Unprotect

Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

TIA
Cheers
Nigel


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Protect/Unprotect Sheet from Macro

Sorry everyone - stupid mistake - its nothing to do with protection the sort
method relies on a selection that I excluded.

Cheers
Nigel

"Nigel" wrote in message
...
Hi All
I have a worksheet that in large part has locked cells, the sheet is then
protected. This of course disables sort. What I am trying to do is
unprotect the sheet, do the sort and then protect the sheet. I have not

as
yet added a password.

If I do the above manually from the UI, all is OK, but the macro that
follows fails on the sort method. The sheet is showing unprotected.

Problem
in both xl97 and xl2002.

ActiveSheet.Unprotect

Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

TIA
Cheers
Nigel




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
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Excel VBA-Protect and unprotect sheet with BVA marfrk Excel Programming 1 May 3rd 04 12:37 PM
Protect/unprotect sheet with password with VBA? dragontale[_7_] Excel Programming 1 April 19th 04 09:29 PM
Macro to protect and unprotect tetreaultl Excel Programming 1 April 1st 04 06:16 PM
VBA code - protect and unprotect a sheet Jeff Excel Programming 2 December 2nd 03 11:44 PM


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