Dim xChk As CheckBox For Each xChk In ActiveSheet.CheckBoxes xName = Right(xChk.Name, Len(xChk.Name) - 10) If (xName = Range(xChk.LinkedCell).Row) Then If (Range(xChk.LinkedCell) = "True") Then Range("A" & xName, Range(xChk.LinkedCell).Offset(0, -2)).Interior.ColorIndex ...
这里要注意控件的名称 4. 插入代码 If CheckBox1.Value = True Then Columns("F").Hidden = True If CheckBox1.Value = False Then Columns("F").Hidden = False 如下图编辑于 2021-03-17 08:23 内容所属专栏 Easy Excel 主要涉及excel基础,函数,数据分析和VBA。 订阅专栏 ...
VBA代码:使用单个复选框选择所有复选框 Sub SelectAll_Click() Update by Extendoffice Dim xCheckBox As CheckBox For Each xCheckBox In Application.ActiveSheet.CheckBoxes If xCheckBox.Name <> Application.ActiveSheet.CheckBoxes("Check Box 1").Name Then xCheckBox.Value = Application.ActiveSheet.CheckBoxes(...
checkboxes in new double quotes. xAllArr = Array("CheckBox1,CheckBox2,CheckBox3", "CheckBox4,CheckBox5,CheckBox6,CheckBox7", "CheckBox8,CheckBox9,CheckBox10") For xI = LBound(xAllArr) To UBound(xAllArr) If InStr(xAllArr(xI), mCheckBoxName) > 0 Then xBol = False xArrItem = Split...
checkboxes in new double quotes. xAllArr = Array("CheckBox1,CheckBox2,CheckBox3", "CheckBox4,CheckBox5,CheckBox6,CheckBox7", "CheckBox8,CheckBox9,CheckBox10") For xI = LBound(xAllArr) To UBound(xAllArr) If InStr(xAllArr(xI), mCheckBoxName) > 0 Then xBol = False xArrItem = Split...
Private Sub CommandButton1_Click() Dim ctr As Control Dim top As Integer For Each ctr In Me.Controls If ctr.Name Like "CheckBox*" Then top = top + ctr.Height + 5 i = i + 1 ctr.top = top ctr.Left = 10 ctr.Caption = "复选框" & i If i Mod ...
1) If CheckBox1.Value = True Then Range("D2").Value = 1 假如选中了复选框那么在单元格D2中记入1 2)If CheckBox1.Value = False Then Range("D2").Value = 0 假如没有选中复选框那么在单元格D2中记入0 实际运行结果(注意要退出设计模式):今日内容回向:1) 如何在工作表中添加复选框按钮?
End If End Sub 五、扩展3:追光灯效果: 实现代码分三部分: 1、开关设置代码: Private Sub CheckBox1_Click() If CheckBox1.Value = False Then CheckBox1.Caption = "关" On Error Resume Next ActiveSheet.Cells.Interior.ColorIndex = xlNone ActiveSheet.Shapes.Range(Array("箭头000")).Delete ...
orderStr = "" For Each ctrls In Me.Controls If TypeName(ctrls) = "CheckBox" Then If ctrls.Value = True Then orderStr = orderStr & "||" & ctrls.Caption End If End If Next ctrls Me.Controls 是一个固定的写法,Me 代表当前窗体,而 Controls 则表示窗体上的所有控件。用 TypeName 函数来...
If arr(i, SplitCol) = Me.CmbSplit Then dicFilter(arr(i, filterCol)) = 1 End If End If Next arrFilter = dicFilter.keys Call SortArray(arrFilter) Me.CmbInclude.List = arrFilter Me.CmbExclude.List = arrFilter Me.CmbInclude = "" Me.CmbInclude = "" End Sub 代码解析:其他筛选,改变...