Thread: Sort
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
N. McCain[_2_] N. McCain[_2_] is offline
external usenet poster
 
Posts: 11
Default Sort

I finally got it to work. Here is some code to help anyone who may need it.
This will allow you to sort the entire sheet ascending by column A. It will
sort 4000 rows and through column L starting at row 3. My sheet is
protected, but I needed to allow the users to use the auto filter feature.
Thanks for everyone's help with this.

Sub ProtectionOptions()
If ActiveSheet.Protection.AllowFiltering = False Then
ActiveSheet.Protect AllowFiltering:=True
End If
End Sub
Private Sub CommandButton1_Click()
ActiveSheet.Unprotect
Range("a3").Activate
Range("a3:L4000").Sort Key1:=Range("a3:l4000")
CommandButton1.Activate
ActiveSheet.EnableAutoFilter = True
ActiveSheet.Protect contents:=True, userInterfaceOnly:=True
End Sub


"N. McCain" wrote:

I need a command button to sort the entire sheet by column "A" in ascending
order. My button is only sorting column "A" and nothing else. Can someone
please help me? Thanks in advance