I had a similar type issue a long while ago. What I did was created a macro
that unprotected the worksheet, did the sorting, then password protected the
worksheet again. This was done in XL97. Your code may look something like:
Workbooks("Book1.xls").Worksheets("Sheet1").Unprotect Password := "Password"
<Put in your sorting/filtering code>
Workbooks("Book1.xls").Worksheets("Sheet1").Protect Password := "Password"
If you are working with Excel 2002 or later, you do have a worksheet
protection option, though there's a catch to it too.
When you protect the worksheet, you can allow for either, or both, Sorting
and Filtering. The catch to this, ALL of the cells within the
sorting/filtering area MUST BE UNPROTECTED with which ever or both of these
options set to "True", in order for the user to sort/filter the sort/filter
area on a protected worksheet.
For more info on this, you can goto Excel VBA help, and look under the
"Protect Method" help page, or the spreadsheet side of the protection under
"About worksheet and workbook protection". However, the VBA help page gives
you more specific information than the spreadsheet side help page does,
which can prove to be very useful.
--
Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
K.Parker said:
Hi,
I would like to ask "How to enable sorting and Filtering" after protecting a worksheet.
Since I don't want users to modify the worksheet don't can use the
Autofilter and sorting function.