ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   enable/disable multiple buttons (https://www.excelbanter.com/excel-discussion-misc-queries/172599-enable-disable-multiple-buttons.html)

Shoney

enable/disable multiple buttons
 
Hello,

A few days back, I received some help for a macro to enable/disable a toggle
button, based on the difference in the value of two different cellsI. That
macro is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Temp As Double
Temp = Range("J4") / Range("H4")
If Temp < 0.5 Then
ToggleButton1.Enabled = True
Else: ToggleButton1.Enabled = False
End If
End Sub

It works great. Now, I want to use a similar macro to enable/disable a
command button (created via Control Toolbox) based on a single cell's value
(say H4, for example) I want the button enabled only if cell H4 is 300 or
higher. I have tried to adjust the above macro to no avail. I want the
current macro to be used for the first button and I want the new macro to run
for this new button.

Any help is appreciated.

Thank you.


Mike

enable/disable multiple buttons
 
Try this should work
Dim Temp2 As Double
Temp2 = Range("H4").Value
If Temp2 = 300 Then
CommandButton1.Enabled = True
Else: CommandButton1.Enabled = False
End If


"Shoney" wrote:

Hello,

A few days back, I received some help for a macro to enable/disable a toggle
button, based on the difference in the value of two different cellsI. That
macro is:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Temp As Double
Temp = Range("J4") / Range("H4")
If Temp < 0.5 Then
ToggleButton1.Enabled = True
Else: ToggleButton1.Enabled = False
End If
End Sub

It works great. Now, I want to use a similar macro to enable/disable a
command button (created via Control Toolbox) based on a single cell's value
(say H4, for example) I want the button enabled only if cell H4 is 300 or
higher. I have tried to adjust the above macro to no avail. I want the
current macro to be used for the first button and I want the new macro to run
for this new button.

Any help is appreciated.

Thank you.



All times are GMT +1. The time now is 02:10 AM.

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