enable/disable multiple buttons

S

Shoney

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.
 
M

Mike

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top