+ Reply to Thread
Results 1 to 9 of 9

change command button colour when selected

  1. #1
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    418

    change command button colour when selected

    Good Morning

    I have several forms with multiple command buttons... all have different names however they all start with 'cmd'

    Is there a way for a button to change colour when selected whilst changing the rest of the buttons on that form to their origional colour... I know how to do it, using this, when the buttons have numbers instead of names....

    Many thanks for your help

    Jim
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by JamesT1; 10-02-2023 at 07:50 AM.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: change command button colour when selected

    see large yellow banner - how to upload your workbook - far easier then to give you a tailor made solution.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    418

    Re: change command button colour when selected

    Thanks torachan

    The attament shows what I am after,, the number buttons change colour when selected with the others returning to their origional colours,,,,.. I'm looking to do this when the buttons have names

    Many thanks

    jim

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: change command button colour when selected

    One way:

    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: change command button colour when selected

    Or, you could add a Tag to all the Names buttons and check that. For example:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    418

    Re: change command button colour when selected

    TMS,,, your 1st one does what I need.. many thanks for your help,,,

    Not sure how tags work just now, so will have a look at that later

    Many thanks

    For your help.. appreciated

    Jim

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: change command button colour when selected

    You're welcome. Thanks for the rep.

    Tag works much the same as caption but you could, for example, make the Name buttons tagged as Name and all the Number buttons tagged as Number. Then you can use the same loop structure.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,466

    Re: change command button colour when selected

    This would probably be a more effective and less repetitive method of highlighting the selected command button(s).

    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,304

    Re: change command button colour when selected

    You could use a class module to intercept the MouseDown and MouseUp conditions - with this method you do not have to intercept each Click event.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 08-31-2017, 12:16 PM
  2. need a command button to change / unchange the colour of specified cells
    By fingermouse in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-09-2014, 09:36 AM
  3. [SOLVED] Command button grayed out till option button selected
    By Jeff121 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2013, 11:00 AM
  4. using a command button to change certain cells font colour.
    By ncaravela in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-17-2013, 10:08 AM
  5. [SOLVED] Change Command Button Colour Based on Cell
    By adam.hewitt5 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-08-2012, 09:43 AM
  6. Colour change of the "Command Button"
    By Johann 12081 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-21-2009, 01:24 PM
  7. command button that changes colour of selected cells
    By BLRITCHIE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2008, 07:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1