'Goes in code pane for worksheet containing checkboxes. Only needed during form development--delete when complete.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Adds a Forms toolbar checkbox to the cell being double-clicked
'Checkbox value is linked to that same cell, using a white font color
With ActiveSheet.CheckBoxes.Add(Target.Left, Target.Offset(1, 0).Top - 15, 50, 10)
.LinkedCell = Target.Address
.Name = "cb" & Target.Address(False, False) 'Name it like "cbA11"
.Caption = IIf(Target.Column < 9, "Verified", "Yes")
.OnAction = "Checkboxer"
End With
Target.Font.ColorIndex = 2 'White font color for linked cell TRUE/FALSE value
Cancel = True
End Sub
'Goes in a regular module sheet
Sub Checkboxer()
Dim celCheckbox As Range
Set celCheckbox = ActiveSheet.Shapes(Application.Caller).TopLeftCell
celCheckbox.Offset(0, 1).Value = IIf(celCheckbox = True, Date, "")
End Sub
|