insert check box to a particular cell through vba macro

后端 未结 3 1457
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 09:26

I would like to insert the check box in particular cell through macro. For example: On click of a command button i should be able to add the check box to A1 cel

3条回答
  •  一生所求
    2021-01-16 09:39

    Slightly upgraded code in the top comment. Simply select a range and run it, it'll fill all selected cells with checkboxes:

    Sub InsertCheckboxes()
        Dim c As Range
    
        For Each c In Selection
            Dim cb As CheckBox
            Set cb = ActiveSheet.CheckBoxes.Add(c.Left, _
                                        c.Top, _
                                        c.Width, _
                                        c.Height)
            With cb
                .Caption = ""
                .Value = xlOff
                .LinkedCell = c.Address
                .Display3DShading = False
            End With
        Next
    End Sub
    

提交回复
热议问题