Sort not working while sheet is protected!?!

J

josua

Hi to all,

I'm using this two command buttons:

Private Sub CommandButton1_Click()
ActiveSheet.Unprotect Password:="*****"
ActiveCell.Offset(1, 0).EntireRow.Insert

Dim c As Range
For Each c In Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row
256))
If Left(c.Formula, 1) = "=" Then
Range(c, c.Offset(1, 0)).FillDown
End If
Next c

ActiveSheet.Protect Password:="*****"

End Sub

Private Sub CommandButton2_Click()

ActiveSheet.Unprotect Password:="*****"
ActiveCell.Offset(0, 0).EntireRow.Delete

ActiveSheet.Protect Password:="*****"

End Sub


The problem is that I can't use "sort" Data>sort. When I manual
protect the sheet in Tools>Protection>Protectsheet (and check the sor
field in "allow all users in this worksheet to" everything is ok bu
when I use the command buttons to Insert or delete a row, the sor
field is gray ?? I'm using Excel2002.
Any help?

Thanks in advance
 
J

Jim Rech

It doesn't seem that you're setting the Allow Sort option:

ActiveSheet.Protect Password:="abc", _ DrawingObjects:=True,
Contents:=True, Scenarios:=True, _
AllowSorting:=True
 
J

josua

Jim said:
*It doesn't seem that you're setting the Allow Sort option:

ActiveSheet.Protect Password:="abc", _ DrawingObjects:=True,
Contents:=True, Scenarios:=True, _
AllowSorting:=True

Thanks Jim, that works just great. Just could you please explain to m
what are this statements for:

DrawingObjects:=True,
Contents:=True,
Scenarios:=True,

Thanks in advance
Josua :
 

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