+ Reply to Thread
Results 1 to 4 of 4

Change color of macro button based on cell value

  1. #1
    Forum Contributor
    Join Date
    04-26-2009
    Location
    Austin, TX
    MS-Off Ver
    Excel 2016
    Posts
    241

    Change color of macro button based on cell value

    I have a macro button called "Button 1".

    I want it to automatically turn green if/when the boolean value in cell R2 is TRUE, and I want it to automatically turn red if/when the boolean value in cell R2 is FALSE.

    I want this behavior to happen without any need to click the button. In fact, the auto changing color is the signal that the user needs to click on the button.

    That's it.

    I have seen related threads on this site, but after hours of trying, I can't adapt the proposed answers there to my situation.

    Please be aware that I am a VBA noob, and need really clear instructions, and the thought of using an Active X control is very, very intimidating because every thread about Active X assumes some familiarity or seems to leave out a step.

    Thanks everyone!

    Jay USA

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Change color of macro button based on cell value

    You cannot change the color of a Forms button. For that you do need an ActiveX button.
    And to have the color changed automatically you do need a little piece of vba. The change event of the sheet could be used for that.
    Also when using an ActiveX button your macro would need to be moved the the button click_event.

    Though this may seem intimidating to you, all that really isn't rocket science and can be explained clearly.
    If you want to procedd I can guide you to make these changes or if you're comfortable you can upload the workbook Then I'll make these changes for you.

    For you to get an idea of what it's all about I'm attachig a sample workbook.
    The sheet has an ActiveX button and a formula in cell R2.
    The formula looks if the value of cell K2 is even. If so it returns True else it returns false.
    The ActiveX button changes color in accordance with the state of cell R2.

    To see what's going on where, open the Developer tab on the ribbon and click View Code.
    If you don't have the Developer tab, right-click on any other ribbon menu and select Customize Ribbon. Then check the Developer checkbox.
    Attached Files Attached Files
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  3. #3
    Forum Contributor
    Join Date
    04-26-2009
    Location
    Austin, TX
    MS-Off Ver
    Excel 2016
    Posts
    241

    Re: Change color of macro button based on cell value

    Tsjallie,

    This is a wonderful, wonderful reply that fully solves my problem! Thank you for your encouragement, the clear structure your provided, and the accurate detail you shared. Excellent!

    JayUSA

  4. #4
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Change color of macro button based on cell value

    Glad I could help. Thx for the rep.
    To finalize this thread pls mark it SOLVED (see Tread Tools in the menu above).
    Unless you have more questions related to the subject of this thread.

+ 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. [SOLVED] how to change the color of a macro button based on a sheet being present or not
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-07-2016, 05:31 PM
  2. [SOLVED] Make cell change color and add text via BUTTON + MACRO
    By Wise_87 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2015, 12:51 AM
  3. Using Macro to change cell color based on reference cell value in different sheet
    By Emma Ford in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-09-2015, 03:51 AM
  4. Macro to change cell text color based on darkness of cell fill color
    By cincyshirm61 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-25-2014, 12:11 PM
  5. [SOLVED] Macro to change color based on drop down in another cell
    By ERaasio in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2013, 06:38 PM
  6. VBA / Macro help needed to change the barchart color based on Cell Color
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2012, 09:15 AM
  7. Creating Macro to Change Cell Color Based on Value
    By JJedi00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2012, 01:12 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