Sorting

i8ig

Board Regular
Joined
Jul 17, 2007
Messages
122
I have a spreadsheet that changes daily, is there a way to add a button to either the spreadsheet or toolbar to sort? I realize you can go thru the menu and select the different variables. However I need to sort the same way each time.
For example I need to sort the dates in Column M in ascending order.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Why not click on Tools, Macro, Record New Macro, and assign the hot keys, Ctrl+S (uppercase s)?
 
Upvote 0
i8ig

Try this, which assumes a heading in M1 of the date column. (It's pretty much what Ralph suggested, only assigning the code to a button rather than a shortcut key)

1. With your workbook open, press Alt+F11 to open the Visual Basic window.
2. Use the VB menu.. Insert|Module
3. Copy the code below and paste into the right hand pane of the VB window that appears after step 2 then close the VB window
4. Back at your sheet, View|ToolBars|Forms
5. Click the "Button" icon and draw a button on your sheet. The "Assign Macro" dialog opens and select "Sort" thern click OK

Try clicking the button. If it is not what you wanted, post back with further details.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Sort()
    <SPAN style="color:#00007F">With</SPAN> Range("M1").CurrentRegion
        .Sort Key1:=Range("M2"), Order1:=xlAscending, Header:= _
            xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top