Question : Run a Sub on Check and Uncheck

Excel 2010

When checkbox is checked I want the first part to run. when unchecked I want the second part to run....is this possible using one checkbox control? Please help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Private Sub CommandButton1_Click()
 If Value = True Then
    Range("C3").Select
    ActiveCell.ClearFormats
    ActiveCell.NumberFormat = "M/D/YYYY"

  Else
    Range("C3").Select
    Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _
        Formula1:="=TODAY()", Formula2:="=TODAY()+15"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16777024
        .TintAndShade = 0
    End With
    With Selection.FormatConditions(1).Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent2
        .TintAndShade = 0.799981688894314
    End With
    Selection.FormatConditions(1).StopIfTrue = False

 End if
End Sub

Answer : Run a Sub on Check and Uncheck

Change your test to the code beneath and it should work (you'll have to change CheckBox1 to whatever name the control has.

If CheckBox1.Value = True Then



Random Solutions  
 
programming4us programming4us