Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro buttons
I already have a couple of macros that sort a particular sheet by one of two columns.
I have them attached to buttons which replace the normal column heading in those two columns. That works fine, but doesnt look very elegant. How do I attach a macro to a normal column heading cell, so it doesnt look any different to the other column headings that dont have macros attached, except with say an underline under the text to indicate that you can sort on those columns ? Not that easy to search for that using google etc. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro buttons
Don't use buttons.
Use worksheet double-click event code to run your macros. You can then have anything you want as column titles. Private Sub Worksheet_BeforeDoubleClick( _ ByVal Target As Excel.Range, Cancel As Boolean) 'Substitute your cells/macro names. Select Case Target.Address(False, False) Case "A1" Cancel = True MyA1Macro Case "B1" Cancel = True MyB1Macro Case "C1" Cancel = True MyC1Macro End Select End Sub Gord Dibben MS Excel MVP On Fri, 23 Apr 2010 08:52:25 +1000, "Rod Speed" wrote: I already have a couple of macros that sort a particular sheet by one of two columns. I have them attached to buttons which replace the normal column heading in those two columns. That works fine, but doesnt look very elegant. How do I attach a macro to a normal column heading cell, so it doesnt look any different to the other column headings that dont have macros attached, except with say an underline under the text to indicate that you can sort on those columns ? Not that easy to search for that using google etc. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro buttons
Thanks for that, knew it had to be something obvious like that.
Gord Dibben wrote: Don't use buttons. Use worksheet double-click event code to run your macros. You can then have anything you want as column titles. Private Sub Worksheet_BeforeDoubleClick( _ ByVal Target As Excel.Range, Cancel As Boolean) 'Substitute your cells/macro names. Select Case Target.Address(False, False) Case "A1" Cancel = True MyA1Macro Case "B1" Cancel = True MyB1Macro Case "C1" Cancel = True MyC1Macro End Select End Sub Gord Dibben MS Excel MVP On Fri, 23 Apr 2010 08:52:25 +1000, "Rod Speed" wrote: I already have a couple of macros that sort a particular sheet by one of two columns. I have them attached to buttons which replace the normal column heading in those two columns. That works fine, but doesnt look very elegant. How do I attach a macro to a normal column heading cell, so it doesnt look any different to the other column headings that dont have macros attached, except with say an underline under the text to indicate that you can sort on those columns ? Not that easy to search for that using google etc. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Assigning macro buttons to macro code in another file | Excel Programming | |||
Macro buttons opening saved macro | Excel Discussion (Misc queries) | |||
Macro Buttons | Excel Worksheet Functions | |||
Replacing macro buttons with a new set of buttons | Excel Programming | |||
VB Macro Buttons | Excel Programming |