PC Review


Reply
Thread Tools Rate Thread

Assigning Functions to Toggle Buttons

 
 
LUKEMUDGE
Guest
Posts: n/a
 
      6th May 2009
I'm trying to make a toggle button change the colour of a cell. I've tried
several variations of the 'IF' function and cannot get it to recognise the
button as a true/false answer to the argument. If anyone can help either with
VB script or an 'IF' argument proceedure that would be fantastic.

Thanks

Luke
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      6th May 2009
If Range("A1").Value > 0 Then
Range("B2").Interior.ColorIndex = 3
Else
Range("B2").Interior.ColorIndex = xlNone
End If



"LUKEMUDGE" <(E-Mail Removed)> wrote in message
newsA68A3B1-6200-457C-82AA-(E-Mail Removed)...
> I'm trying to make a toggle button change the colour of a cell. I've tried
> several variations of the 'IF' function and cannot get it to recognise the
> button as a true/false answer to the argument. If anyone can help either
> with
> VB script or an 'IF' argument proceedure that would be fantastic.
>
> Thanks
>
> Luke



 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      6th May 2009
Assuming you wanted to toggle the cell's color between Red and None, just
use this single line of code in your toggle button's event procedure...

Range("A1").Interior.ColorIndex = -4139 - Range("A1").Interior.ColorIndex

The way to figure out the number (-4139 for my example code) is to add -4142
(the value of xlNone) and the ColorIndex value for the color you want (3
being Red in my example code)...

-4142 + 3 = -4139

Just use the ColorIndex in place of the value 3 in above.

--
Rick (MVP - Excel)


"LUKEMUDGE" <(E-Mail Removed)> wrote in message
newsA68A3B1-6200-457C-82AA-(E-Mail Removed)...
> I'm trying to make a toggle button change the colour of a cell. I've tried
> several variations of the 'IF' function and cannot get it to recognise the
> button as a true/false answer to the argument. If anyone can help either
> with
> VB script or an 'IF' argument proceedure that would be fantastic.
>
> Thanks
>
> Luke


 
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
have toggle buttons but everytime print preview buttons move =?Utf-8?B?VGluU2FuZGh1?= Microsoft Excel Misc 1 11th Oct 2006 02:57 PM
Toggle Buttons =?Utf-8?B?QmlsbA==?= Microsoft Excel Programming 1 16th May 2006 06:44 PM
Toggle Buttons =?Utf-8?B?V29ya3Nob3A=?= Microsoft Access Forms 2 6th Mar 2005 04:39 PM
assigning functions/commands to gamepad buttons P. Jayant Windows XP Games 1 6th Jan 2004 05:35 AM
Many Toggle Buttons Rachel Microsoft Access Form Coding 2 1st Aug 2003 10:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.