在选中复选框后,我正在使用以下内容将今天的日期插入到 Excel 单元格中。我想更改它,以便插入即将到来的星期日的日期。我尝试使用 Weekday 函数,但语法不正确,或者这不是正确的方法。你能帮我吗?
Sub Process_CheckBox()
Dim cBox As CheckBox
Dim LRow As Integer
Dim LRange As String
LName = Application.Caller
Set cBox = ActiveSheet.CheckBoxes(LName)
'Find row that checkbox resides in
LRow = cBox.TopLeftCell.Row
LRange = "D" & CStr(LRow)
'Change date in column D, if checkbox is checked
If cBox.Value > 0 Then
ActiveSheet.Range(LRange).Value = Date
'Clear date in column D, if checkbox is unchecked
Else
ActiveSheet.Range(LRange).Value = Null
End If
End Sub