Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro To Create Other Macros And Buttons
I create Excel spreadsheets to track all kinds of sports statistics. I would
like to programmatically place two buttons above each column that contains data to sort based on that column. This gives the users a quick way to sort. So, in A1 I'd have a (+) button and a (-) button. The actual data would start in A2. The buttons would run macros to sort ascending (+) or sort descending (-). This is a tedious process manually. I need to write macros then I need to place buttons then assign macros. I would like to define the macros along with the buttons inside another macro. Is this possible? This is a sample of the macros that I currently use: Sub d_kick_td_asc() Call rank("AF6", "A") End Sub Sub d_kick_td_desc() Call rank("AF6", "D") End Sub Function rank(col, upd) If (col = "") Then col = "A6" If (upd = "A" Or upd = "a") Then upd = xlAscending Else upd = xlDescending End If *Range("all").Select Selection.Sort Key1:=Range(col), Order1:=upd, Header:=xlNo, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom ActiveWindow.LargeScroll ToRight:=-1 ActiveWindow.LargeScroll Down:=-6 ActiveWindow.ScrollRow = 7 ActiveWindow.ScrollRow = 6 Range(col).Select End Function *Note: "all" has been previously defined. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to create Sort buttons | Excel Discussion (Misc queries) | |||
Macros AND Buttons | Excel Worksheet Functions | |||
Sharing macros and buttons that accompany the macro | Excel Discussion (Misc queries) | |||
How do I create a scroll list of macro buttons? | Excel Discussion (Misc queries) | |||
buttons & macros | Excel Worksheet Functions |