ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I make a check box highlight cells if true? (https://www.excelbanter.com/excel-programming/351533-how-do-i-make-check-box-highlight-cells-if-true.html)

BrianXJ

How do I make a check box highlight cells if true?
 
I'm trying to add a check box so that when checked, it will highlight certain
cells. I've been trying to write a Macros for it and can't figure it out...
any help?

Tom Ogilvy

How do I make a check box highlight cells if true?
 
If using a checkbox from the Control Toolbox Toolbar, then place it on the
sheet and double click on it. This should take you to the click event

Private Sub Checkbox1_Click()

end Sub

put code in here
Private Sub Checkbox1_Click()
if Checkbox1.Value = True then
Range("A5:F20").Interior.ColorIndex = 3
else
Range("A5:F20").Interior.ColorIndex = xlNone
End if
end Sub

return to excel and in the control toolbox toolbar, click the top right
control so it does not appear depressed. This takes you out of design mode
and allow the events to fire when you click the control.

Adjust to suit.

--
Regards,
Tom Ogilvy


"BrianXJ" wrote in message
...
I'm trying to add a check box so that when checked, it will highlight

certain
cells. I've been trying to write a Macros for it and can't figure it

out...
any help?





All times are GMT +1. The time now is 11:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com