+ Reply to Thread
Results 1 to 6 of 6

command button color changed while cells value change and else...

  1. #1
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    174

    Smile command button color changed while cells value change and else...

    Hi Guys,

    I need your golden brain to write code:
    1. how to change command button color while the cell value is changed "WITHOUT CLICK" in command button", by meant it will be updated automatically while the cell value is changed.
    Lets say: if Cell: A5 = 0 then the command button = red, and if cell A5 = 1 then the command button = white
    is it possible?

    2. How to draw shape in userform?

    3. How to write code from command buttons to change in the same cell value . Let's say if command button1_click: cell B5 = 0 and if command button2_click: cell B5 = 1

    Thanks in advance
    Iqballud

  2. #2
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: command button color changed while cells value change and else...

    hi,
    draw a Commandbutton on your sheet and add this piece of code to worksheet change event
    1.
    Please Login or Register  to view this content.
    2.it's very difficult

    3.
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  3. #3
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: command button color changed while cells value change and else...

    Hi John, thanks a lot for your answered.
    1. The code is not working.
    2. It's OK, i will try to find another way.
    3. It's working fine.
    Also i am tried to change the code Range to Cells, the commandButton1 the value is kept and the quote is removed, the commandButton2-the value was removed also the quote is removed. And all of this code are working too.
    Is there any difference between Range and Cells? when i removed Value, this is working too, included while i am removed the quote.
    Here is the code:
    Private Sub CommandButton1_Click()
    Cells(5, 2).Value = 0
    End Sub
    Private Sub CommandButton2_Click()
    Cells(5, 2) = 1
    End Sub

    Thanks in advanced.
    Iqbal

  4. #4
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: command button color changed while cells value change and else...

    1. see the file attached, it works for me.

    cells is used to refer to Single cell. while we use Range to refer to more than one cell.in yr case you can use both as well because you have a single cell.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    11-17-2013
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    174

    Re: command button color changed while cells value change and else...

    John, again big thanks to you.

    Cheers.
    Iqbal

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: command button color changed while cells value change and else...

    You're welcome!

+ 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. 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
  2. Add command button to shape and change shape color on mouseover
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2012, 05:12 PM
  3. Cell value is changed, the cells change the color
    By lsuersoy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-06-2010, 07:17 AM
  4. Changing cells color without clicking command button
    By grumpyguppy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-19-2008, 03:22 AM
  5. [SOLVED] change the face color of an Excel command button
    By Chris Leah in forum Excel General
    Replies: 4
    Last Post: 07-12-2005, 10:05 AM

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