#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checkbox


I need to highlight (color-fill) a cell when a checkbox is clicked an
then be able to unclick and have the cell have no-fill.

anyone know how to do this?

Cadbur

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Checkbox

Where is your checkbox? On UserForm or Worksheet?

Anyway, to color a cell, for example, yellow:

range("A1").Interior.ColorIndex = 6

To remove the color:
range("A1").Interior.ColorIndex = xlNone

To discover more "colorindex", you may try using the "Record Macro" function of Excel.

In fact, the Record Macro function is a very very good way to learn VBA.

Regards,
Edwin Tam


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checkbox


The Checkbox is in a worksheet

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Checkbox

So, create the following macro in a module, then assign it to the checkbox on your worksheet.

Sub CheckBox1_Click()
With ActiveSheet.CheckBoxes("Check Box 1")
If .Value = xlOn Then
Range("A1").Interior.ColorIndex = 6
Else
Range("A1").Interior.ColorIndex = xlNone
End If
End With
End Sub

----- cadbury wrote: -----


The Checkbox is in a worksheet.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Checkbox

Cadbury,

Here is an approach where you don't need VBA for this.
You can use a linked cell in combination with conditional
formatting.

1. Create the checkbox

2. If the checkbox is from the "Forms" toolbar:
- Right-Click the checkbox and select "Format Control"
- Select the Control tab
- Set cell link to A1
- Click OK

If the checkbox is fron the "Control Toolbox" toolbar:
- Right-Click the checkbox and select "Properties"
- Set the cell link property to A1
- Close the properties window
- Click the "Exit Design Mode" toolbar button

3. Select the cell you want to color

5. Format - Conditional Formatting
Formula is... =A1=TRUE
Click Format, set Red color on Patterns tab

6. Click OK, twice

--
Ture Magnusson
Microsoft MVP - Excel
Karlstad, Sweden

"cadbury" wrote in message
...

I need to highlight (color-fill) a cell when a checkbox is clicked and
then be able to unclick and have the cell have no-fill.

anyone know how to do this?

Cadbury


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checkbox


The non-VBA is the better way for me to go, but the cell that highlights
also says "true" or "false", depending on the checkbox. How can I make
it so true or false doesn't replace the text already in the cell.

Thanks for your help

Cadbury


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Checkbox


I figured out a solution. I made the text color part of the conditional
formatting, the true and false are still there, they just blend in with
the cell color. If there is a better way, please let me know.

Cadbury


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Checkbox

Cadbury,

I often set the checkbox's cell link to the cell behind the
checkbox and set the number format of that cell to the
custom format ;;;

--
Ture Magnusson
Microsoft MVP - Excel
Karlstad, Sweden

"cadbury" wrote in message
...

I figured out a solution. I made the text color part of the conditional
formatting, the true and false are still there, they just blend in with
the cell color. If there is a better way, please let me know.

Cadbury


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



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
CheckBox Q Sean Excel Worksheet Functions 1 February 15th 08 10:21 AM
How to have Checkbox A uncheck with checked Checkbox B Texas Aggie Excel Discussion (Misc queries) 3 July 20th 07 10:58 PM
checkbox Chas Excel Worksheet Functions 2 May 13th 05 10:37 PM
checkbox Paul P Excel Programming 0 September 10th 03 08:56 PM
checkbox mark Excel Programming 1 August 1st 03 09:47 PM


All times are GMT +1. The time now is 10:21 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"