Not able to sort whole rows

K

Khalil Handal

Hi,
I have a protected sheet with password say "1122"
In the protection window I have checked the box of "Sort"
I selected whole lines from 14 to 40 and tried the: Data|Sort and had the
error message:
"The cell or chart you are trying to change is protected and therefore
read-only..."

Any sugestion how to solve this using a macro or VBA code for a button
click.

I need to sort according to column F (which is hidden).

Second:
What code do I need to hide 2 groups of columns:
DR:FQ and G:AB
 
G

Gord Dibben

Unprotect, do the sort then reprotect.

Sub foo()
ActiveSheet.Unprotect Password:="pword"

''your sort code

ActiveSheet.Protect Password:="pword"
End Sub


Sub hide()
ActiveSheet.Range("G:AB,DR:FQ").EntireColumn.Hidden = True
End Sub
 
K

Khalil Handal

Thanks,
It worked fine.

Gord Dibben said:
Unprotect, do the sort then reprotect.

Sub foo()
ActiveSheet.Unprotect Password:="pword"

''your sort code

ActiveSheet.Protect Password:="pword"
End Sub


Sub hide()
ActiveSheet.Range("G:AB,DR:FQ").EntireColumn.Hidden = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top