![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 20
|
Trying to set a condition on a checkbox, so when the box is selected (checked), the text in specific range of cells turn red. When unchecked, they turn back to the original color (black).
Help would be appreciated. exceldvlpr |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Hi,
Assuming that your checkbox is from the control toolbox and not from the forms toolbar you can use something like this: Make sure you're in design mode and double click the checkbox. This should create a blank procedure called something like CheckBox1_Click. This code will make the cells in A1:A10 red when the checkbox is ticked and black when unticked. Private Sub CheckBox1_Click() If Me.CheckBox1.Value = True Then Me.Range("A1:A10").Font.Color = vbRed Else Me.Range("A1:A10").Font.Color = vbBlack End If End Sub HTH, Dan |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Portland, OR USA
Posts: 1,374
|
I would suggest that you put the code in the Change event instead of the Click event. While the check box will change each time it is clicked, you can also click on the box, then use the spacebar to check and uncheck it. Let us know if you need help getting to the Change event.
-Russell |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|