我选择了以下宏来选择活动单元格时的整行。这完美地运作了!但是,我只想在选中复选框&#34; <#34;
时使此宏工作Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column <> 1 Then
Exit Sub
Else
Application.ScreenUpdating = False
Cells.Borders.LineStyle = xlLineStyleNone
Rows(Target.Row).BorderAround Weight:=xlMedium, ColorIndex:=3
Application.ScreenUpdating = True
End If
End Sub
答案 0 :(得分:0)
取决于您拥有的复选框的名称。但是,如果它是CheckBox1
,这应该是什么If CheckBox1.Value = True Then
'do code'
Else: End If
答案 1 :(得分:0)
您可以按名称调用复选框,然后选择值属性
CheckBoxName.Value
如果选中则返回true,如果未选中则返回false。所以你可以打电话给
If CheckBoxName.Value
If Target.Column <> 1 Then
Exit Sub
Else
Application.ScreenUpdating = False
Cells.Borders.LineStyle = xlLineStyleNone
Rows(Target.Row).BorderAround Weight:=xlMedium, ColorIndex:=3
Application.ScreenUpdating = True
End If
End If
这应该有用。
答案 2 :(得分:0)
您应该可以右键单击复选框并选择分配宏。
http://blog.contextures.com/archives/2014/01/16/click-a-check-box-to-run-a-macro/
答案 3 :(得分:0)
感谢您的努力和时间,但我找到了解决方案:
如果是ActiveSheet.Shapes(&#34;复选框1&#34;)。ControlFormat.Value = 1那么
答案 4 :(得分:0)
不确定这是多么相关,但我注意到你可以直接将宏分配给复选框......?