Hi,
Try it this way:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Temp As Double
If Target.Address = "$J$4" Or Target.Address = "$H$4" Then
Temp = Range("J4") / Range("H4")
togglebutton1.Enabled = Temp < 0.5
ElseIf Target.Address = "$L$4" Then
ToggleButton2.Enabled = Range("L4").Value >= 300
End If
End Sub
--
Hope that helps.
Vergel Adriano
"Shoney" wrote:
> Hi,
>
> I'm trying to disable multiple toggle buttons (ToggleButton1 and
> ToggleButton2). I am currently using this code for ToggleButton1:
>
> 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
>
> ...and it works great.
>
> But now, I have another toggle button on the same sheet and I want it to be
> enabled only if cell L4 is greater than or equal to 300. I've searched the
> site and tried everything I can think of, to no avail.
>
> If it is possible to enable/disable multiple toggle buttons on the same
> worksheet, please let me know how I should adjust my code or what additional
> code I need to use to make it work.
>
> Thank you.
|