I would like to have a button in excel where as anytime i pressed it, it would sort by column K from largest to the smallest.
Is this an easy task?
I would like to have a button in excel where as anytime i pressed it, it would sort by column K from largest to the smallest.
Is this an easy task?
Hello realized,
![]()
Sub SortColumnK() Dim Rng As Range Dim RngEnd As Range Dim Wks As Worksheet Set Wks = Worksheets("Sheet1") 'Assumes header row is row 1 Set Rng = Wks.Range("K2") Set RngEnd = Wks.Cells(Rows.Count, Rng.Column).End(xlUp) If RngEnd.Row < Rng.Row Then Exit Sub 'No data to sort Set Rng = Wks.Range(Rng, RngEnd) Rng.Sort Key1:=Rng.Cells(1, 1), Order1:=xlDescending, Header:=xlNo, _ Orientation:=xlTopToBottom, MatchCase:=False End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Thank you!!
How do i make a custom button to put that in ? So its always in excel ?
Excel 2007
Hi realized
And a great Fantastic Hi to Leith. You know "realized" with Leith, you are working with someone that I believe is untouchable. He really is Fantastic and he has helped me with some very deep code. Thanks Leith.
Realized . . . I don't know if you ever need to sort by different columns on the same worksheet, but I will throw out my idea that may help you in the future.
I have 18 out of 24 columns that I want to sort by at any particular time.
First, I entered my column names, then I used a text box for each column without any fill (can see through). I do not type a name into the text box as you can see the column header through the text box. Then you can right click on the text box and assign the macro for that particular column.
As soon as you accomplish Leith's code, you can use it also for mine. A difference being that he is using a range for the data to be sorted and I set my range inside my code and it also expands as more rows are added.
Leith . . . Call me some time when you have time.
Matt Gentry Sr.
909-702-3307
Thanks for helping . . .
Matt @ Launchnet
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks