Select View >> Toolbars >> Control Toolbox to display the Control Toolbox
toolbar. Add a check box to your worksheet. Right-click on the checkbox and
select View Code. The Visual Basic Editor (VBE) is displayed with an empty
subroutine for the Click event for the checkbox. Probably the following:
Private Sub CheckBox1_Click()
End Sub
Paste the following code in the subroutine (between those two lines):
Range("A3:C3").Select
If CheckBox1.Value = True Then
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = 6
With Selection.Borders(xlEdgeLeft)
.ColorIndex = 6
End With
With Selection.Borders(xlEdgeTop)
.ColorIndex = 6
End With
With Selection.Borders(xlEdgeBottom)
.ColorIndex = 6
End With
With Selection.Borders(xlEdgeRight)
.ColorIndex = 6
End With
Else
With Selection.Interior
.ColorIndex = xlAutomatic
.Pattern = xlSolid
End With
Selection.Font.ColorIndex = xlAutomatic
With Selection.Borders(xlEdgeLeft)
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.ColorIndex = xlAutomatic
End With
End If
This is basically code I recorded with the macro recorder. It will color the
merged cells' font, background, and borders yellow when the checkbox is
checked. Unchecking the checkbox restores the cells to the default black on
white colors.
Save the workbook, then select File >> Close (in the VBE) to return to
regular Excel. Click the 'Exit Design Mode' button on the Control Toolbox
toolbar (probably the first button), and try out your new checkbox.
If you are new to macros, this link to Jon Peltier's site may be helpful:
http://peltiertech.com/WordPress/2008/03/09/how-to-use-someone-elses-macro/
Hope this helps,
Hutch