Im working on a project checklist. When creating new projects, I would like to insert a new row on row 10. Copy the checkboxes from row 11 below, link and set the checkbox functions to work seperatly...so far so good.
However, now I would like to reset all the "newly" created checkboxes to unchecked or "xloff" for all checkboxes on row 10. The range where checkboxes are located is L10:Y10.
As I will constantly create new checkboxes on row 10, I suppose I need class, event, msform?? Im just guessing after a few days of research....Im not really getting anywhere and I feel clueless
Appreciate all your help.
My code so far looks like below.
However, now I would like to reset all the "newly" created checkboxes to unchecked or "xloff" for all checkboxes on row 10. The range where checkboxes are located is L10:Y10.
As I will constantly create new checkboxes on row 10, I suppose I need class, event, msform?? Im just guessing after a few days of research....Im not really getting anywhere and I feel clueless
Appreciate all your help.
My code so far looks like below.
Code:
Option Explicit
Sub LinkCheckBoxes()
Dim chk As CheckBox
Dim lCol As Long
lCol = 62 'number of columns to the right for link
For Each chk In ActiveSheet.CheckBoxes
With chk
.LinkedCell = _
.TopLeftCell.Offset(0, lCol).Address
End With
Next chk
End Sub
Sub CheckBoxDate()
Dim ws As Worksheet
Dim chk As CheckBox
Dim lColD As Long
Dim lColChk As Long
Dim lRow As Long
Dim rngD As Range
lColD = 84 'number of columns to the right for date
Set ws = ActiveSheet
Set chk = ws.CheckBoxes(Application.Caller)
lRow = chk.TopLeftCell.Row
lColChk = chk.TopLeftCell.Column
Set rngD = ws.Cells(lRow, lColChk + lColD)
Select Case chk.Value
Case 1 'box is checked
rngD.Value = Date
Case Else 'box is not checked
rngD.ClearContents
End Select
End Sub
Sub CheckBoxDate()
Dim ws As Worksheet
Dim chk As CheckBox
Dim lColD As Long
Dim lColChk As Long
Dim lRow As Long
Dim rngD As Range
lColD = 84 'number of columns to the right for date
Set ws = ActiveSheet
Set chk = ws.CheckBoxes(Application.Caller)
lRow = chk.TopLeftCell.Row
lColChk = chk.TopLeftCell.Column
Set rngD = ws.Cells(lRow, lColChk + lColD)
Select Case chk.Value
Case 1 'box is checked
rngD.Value = Date
Case Else 'box is not checked
rngD.ClearContents
End Select
End Sub
Sub SetCheckBoxesMacro()
Dim chk As CheckBox
For Each chk In ActiveSheet.CheckBoxes
chk.OnAction = "CheckBoxDate"
Next chk
End Sub