Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Assigning Functions to Toggle Buttons

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Assigning Functions to Toggle Buttons

If Range("A1").Value 0 Then
Range("B2").Interior.ColorIndex = 3
Else
Range("B2").Interior.ColorIndex = xlNone
End If



"LUKEMUDGE" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Assigning Functions to Toggle Buttons

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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle buttons FloMM2 Excel Programming 3 August 7th 07 07:52 PM
have toggle buttons but everytime print preview buttons move TinSandhu Excel Discussion (Misc queries) 1 October 11th 06 02:57 PM
Toggle Buttons Bill Excel Programming 1 May 16th 06 06:44 PM
Toggle command buttons GEB Excel Programming 4 June 23rd 05 08:33 PM
Toggle Buttons Momo Excel Programming 2 February 9th 05 01:35 PM


All times are GMT +1. The time now is 12:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"