PC Review


Reply
Thread Tools Rate Thread

disable multiple toggle buttons

 
 
Shoney
Guest
Posts: n/a
 
      15th Jan 2008
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.
 
Reply With Quote
 
 
 
 
Vergel Adriano
Guest
Posts: n/a
 
      15th Jan 2008
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.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle Buttons mustangric2001 Microsoft Access Forms 3 1st Aug 2008 03:30 PM
enable/disable multiple buttons Shoney Microsoft Excel Misc 1 11th Jan 2008 02:41 AM
Toggle buttons =?Utf-8?B?RmxvTU0y?= Microsoft Excel Programming 3 7th Aug 2007 07:52 PM
have toggle buttons but everytime print preview buttons move =?Utf-8?B?VGluU2FuZGh1?= Microsoft Excel Misc 1 11th Oct 2006 02:57 PM
multiple toggle buttons =?Utf-8?B?TmVsc29u?= Microsoft Excel Programming 3 2nd Nov 2004 08:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 AM.