如果可以将另一个事件添加到VBA Excel中的复选框,我就会徘徊。我创建了一个像这样的复选框:
ActiveSheet.CheckBoxes.Add(.Left, .Top,.Width, .Height).Select
With Selection
.Caption = ""
.LinkedCell = "AN2"
.Value = xlOn
End With
我想知道是否可以添加代码,以便每当有人检查时,某个单元格会获得当前日期,如:
Cells(1,"A").Now()
干杯!
答案 0 :(得分:0)
正如@Rory所说,answear是:
添加" .OnAction ="宏的名称"然后你可以编写一个对应于点击的宏:
With Selection
.Caption = ""
.LinkedCell = "AN2"
.Value = xlOff
.OnAction = "DateClicked"
End With
Function DateClicked()
If Cells(2,"AN") = "TRUE" Then
Cells(2,"A") = Now()
Else
Cells(2,"A") = ""
End If
End Function