在Excel VBA中自动selectcheckbox

我保留了一个Excel表格,其中列A中列出了特定产品的所有参数,而在列D中,还有几个参数,我需要从列A中所有参数的集合中进行select。

是否有可能在VBA触发一个点击事件,它应该比较列A和列D,并selectcheckbox,如果它自动find参数。

在这里输入图像说明

任何帮助表示赞赏!

好的你可以做的是这样的:

把C列中的checkbox(确保它们是格式控制checkbox)。(确保checkbox完全在单元格中)

在Worksheetmodul中发布:

 Private Sub Worksheet_Change(ByVal Target As Range) Dim chk As CheckBox Dim check As Boolean Dim rng As Range For Each chk In ActiveSheet.CheckBoxes Set rng = Range("D:D").Find(what:=chk.TopLeftCell.Offset(0, -2).Value, _ LookIn:=xlValues, _ lookat:=xlWhole, _ searchorder:=xlByRows, _ searchdirection:=xlNext, _ MatchCase:=False) If Not rng Is Nothing Then chk.Value = True End If Next chk End Sub 

每次在工作表中更改一个值时,都会触发该子项。