Protected sheet becomes unprotected after sort...?

richard.ca

Board Regular
Joined
Nov 7, 2007
Messages
100
I am just trying out the protect sheet with UserInterFaceOnly option (running an ancient Excel 2000) to avoid having
to unprotect/protect every time my code wants to make a change on the sheet. Eg:

Code:
Sheets("sheet name").Protect "password", UserInterFaceOnly:=True

In general it seems to work fine but then I found something peculiar with sorting: the sheet somehow becomes
unprotected after I run the following sort code:

Code:
Range(my_range).CurrentRegion.Sort Key1:=Range(my_range), Order1:=xlAscending, header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

The sort function works normally and does not seem to produce any other unexpected side effects apart from leaving
the sheet unprotected. I assume this has to be a bug of some sort. Not really a huge issue since I can simply
reprotect the sheet after calling sort; the point is it shouldn't really be necessary.

Anyone else encountered this problem? I would imagine it has been fixed in later versions of Excel...
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi Richard,

Are you able to perform the sort in a protected sheet ?

Regards,
DILIPandey
 
Upvote 0
Hi DILIPandey,

Yes, sort on the protected sheet works (as I would expect with the UserInterFaceOnly only option).
The only problem seems to be that the sheet is left unprotected after the sort function is called.

Regards,

Richard.
 
Upvote 0

Forum statistics

Threads
1,216,129
Messages
6,129,046
Members
449,482
Latest member
al mugheen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top