ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Command Button Color (https://www.excelbanter.com/excel-programming/370431-excel-command-button-color.html)

justbrewit

Excel Command Button Color
 

Suppose I have a spreadsheet that does a number of calculations. I hav
a command button which I use to execute the solutions.

1. I would like the button to turn green (or some color) when th
solution has converged, which I can check at any time

2. If a change to any parameter is made (and thus the former solutio
is not a solution for the new case) I would like to change the color
to red for example.

i would appreciate it if someone could help me figure out how t
accomplish this, particularly the second part.


Thank yo

--
justbrewi
-----------------------------------------------------------------------
justbrewit's Profile: http://www.excelforum.com/member.php...fo&userid=3753
View this thread: http://www.excelforum.com/showthread.php?threadid=57179


Tom Ogilvy

Excel Command Button Color
 
if the solution is arrived at through iterative calculations in a single
calculation event, then you can not take actions inside that event.

If you code performs the calculations, then just add code to color the
button based on the conditions within your code.

--
Regards,
Tom Ogilvy


"justbrewit" wrote:


Suppose I have a spreadsheet that does a number of calculations. I have
a command button which I use to execute the solutions.

1. I would like the button to turn green (or some color) when the
solution has converged, which I can check at any time

2. If a change to any parameter is made (and thus the former solution
is not a solution for the new case) I would like to change the color,
to red for example.

i would appreciate it if someone could help me figure out how to
accomplish this, particularly the second part.


Thank you


--
justbrewit
------------------------------------------------------------------------
justbrewit's Profile: http://www.excelforum.com/member.php...o&userid=37539
View this thread: http://www.excelforum.com/showthread...hreadid=571792



raypayette[_49_]

Excel Command Button Color
 

This is fairly straight forward if you use VBE and a User Defined Form.
Is that the case or are you using the buttons from the worksheet tool?


--
raypayette


------------------------------------------------------------------------
raypayette's Profile: http://www.excelforum.com/member.php...o&userid=29569
View this thread: http://www.excelforum.com/showthread...hreadid=571792


Dave Peterson

Excel Command Button Color
 
Option Explicit
Private Sub CommandButton1_Click()
'your code to do all the work here
if somethinggoodhappened = true then
Me.CommandButton1.BackColor = &HFF00&
else
me.commandbutton1.backcolor = &HFF&
end if
End Sub


justbrewit wrote:

Suppose I have a spreadsheet that does a number of calculations. I have
a command button which I use to execute the solutions.

1. I would like the button to turn green (or some color) when the
solution has converged, which I can check at any time

2. If a change to any parameter is made (and thus the former solution
is not a solution for the new case) I would like to change the color,
to red for example.

i would appreciate it if someone could help me figure out how to
accomplish this, particularly the second part.

Thank you

--
justbrewit
------------------------------------------------------------------------
justbrewit's Profile: http://www.excelforum.com/member.php...o&userid=37539
View this thread: http://www.excelforum.com/showthread...hreadid=571792


--

Dave Peterson

justbrewit[_2_]

Excel Command Button Color
 

Thanks for the help, but I am not sure that I am being totally clear.

After I run the VB code and find a solution to my equations, can I
(somehow) change the button color if any cell in the workbook is
modified by the user?


--
justbrewit
------------------------------------------------------------------------
justbrewit's Profile: http://www.excelforum.com/member.php...o&userid=37539
View this thread: http://www.excelforum.com/showthread...hreadid=571792


Dave Peterson

Excel Command Button Color
 
If any cell is changed in the workbook????

This code goes behind the ThisWorkbook module:

Option Explicit
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Me.Worksheets("sheet2").OLEObjects("commandbutton1 ").Object.BackColor _
= &HFF&
End Sub

Change the sheet name and the commandbutton name to match.

justbrewit wrote:

Thanks for the help, but I am not sure that I am being totally clear.

After I run the VB code and find a solution to my equations, can I
(somehow) change the button color if any cell in the workbook is
modified by the user?

--
justbrewit
------------------------------------------------------------------------
justbrewit's Profile: http://www.excelforum.com/member.php...o&userid=37539
View this thread: http://www.excelforum.com/showthread...hreadid=571792


--

Dave Peterson


All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com