Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning macro buttons to macro code in another file Enz Excel Programming 2 May 25th 09 06:44 PM
Macro buttons opening saved macro Wasabijim Excel Discussion (Misc queries) 0 April 29th 09 08:39 PM
Macro Buttons Lois Excel Worksheet Functions 4 April 1st 09 03:33 PM
Replacing macro buttons with a new set of buttons jonco Excel Programming 3 July 3rd 06 01:36 AM
VB Macro Buttons Keda Wang Excel Programming 1 January 23rd 04 04:30 AM


All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"