ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort (https://www.excelbanter.com/excel-programming/406716-sort.html)

N. McCain

Sort
 
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

Don

Sort
 
Just a thought...have you selected the entire sheet before the sort action?

"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


Jim Thomlinson

Sort
 
Post your code... How many columns are there to sort...
--
HTH...

Jim Thomlinson


"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


N. McCain[_2_]

Sort
 
Private Sub CommandButton1_Click()
Range("a3").Activate
Range("a3:a4000").sort Key1:=Range("a3")
CommandButton1.Activate
End Sub

I need to be able to sort 4000 rows and columns A-L.

"Jim Thomlinson" wrote:

Post your code... How many columns are there to sort...
--
HTH...

Jim Thomlinson


"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


N. McCain[_2_]

Sort
 
Also I need it to start sorting at row 3

"N. McCain" wrote:

Private Sub CommandButton1_Click()
Range("a3").Activate
Range("a3:a4000").sort Key1:=Range("a3")
CommandButton1.Activate
End Sub

I need to be able to sort 4000 rows and columns A-L.

"Jim Thomlinson" wrote:

Post your code... How many columns are there to sort...
--
HTH...

Jim Thomlinson


"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


Gary Keramidas

Sort
 
change the a4000 to b4000, c4000 or whatever the last column you want to include
in the sort.

--


Gary


"N. McCain" wrote in message
...
Also I need it to start sorting at row 3

"N. McCain" wrote:

Private Sub CommandButton1_Click()
Range("a3").Activate
Range("a3:a4000").sort Key1:=Range("a3")
CommandButton1.Activate
End Sub

I need to be able to sort 4000 rows and columns A-L.

"Jim Thomlinson" wrote:

Post your code... How many columns are there to sort...
--
HTH...

Jim Thomlinson


"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




N. McCain[_2_]

Sort
 
I have figured out how to get it all to sort thanks to Don pointing out that
I needed to try and select the entire sheet. Below is my code. However, I
have one more question/problem. I need this sheet to be protected. When I
protect the sheet and then click the button, I get an error. When the sheet
is unprotected, it will sort just fine. What code, if any, will help me sort
this while the sheet is protected?

Private Sub CommandButton1_Click()
Range("a3").Activate
Range("a3:L4000").sort Key1:=Range("a3:l4000")
CommandButton1.Activate
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


N. McCain[_2_]

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



All times are GMT +1. The time now is 10:58 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com