在每个单元格中插入一个复选框,并将其分配给该单元格 [英] Insert a Checkbox into every cell and assign it to that cell

查看:282
本文介绍了在每个单元格中插入一个复选框,并将其分配给该单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为链接到该单元格的每个单元格添加一个复选框.选中后将返回true,而未选中时将返回false到分配给它的单元格中.

I need to add a checkbox to every cell which is linked to that cell. When checked it will return true, when unchecked it returns false into the cell it is assigned to.

工作表中有成千上万个单元格,当我手动插入它们时,我意识到必须有一个更好的解决方案.

The worksheet has thousands of cells, and as I'm going through inserting them manually, I realize there has to be a better solution.

我正在处理的工作表如下所示:

The sheet I am working on looks like this:

推荐答案

克林顿,您在这里.

Sub AddCheckBoxes()

Dim cb As CheckBox
Dim myRange As Range, cel As Range
Dim wks As Worksheet

Set wks = Sheets("mySheet") 'adjust sheet to your needs

Set myRange = wks.Range("A1:A10") ' adjust range to your needs

For Each cel In myRange

    Set cb = wks.CheckBoxes.Add(cel.Left, cel.Top, 30, 6) 'you can adjust left, top, height, width to your needs


    With cb

        .Caption = ""
        .LinkedCell = cel.Address

    End With

Next

End Sub

这篇关于在每个单元格中插入一个复选框,并将其分配给该单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆