VBA中的CheckBoxes集合和CheckBox类型(对于Excel)

时间:2018-06-21 06:48:06

标签: excel vba excel-vba checkbox intellisense

我不得不遍历活动工作表上的复选框,并试图将变量声明为复选框,但是 IntelliSense 没有提供该自动填充选项。我继续输入,按Enter后,VBA识别出它-它会自动更改为正确的表示形式CheckBox。

我的下一步是循环遍历Activesheet中的CheckBoxes集合,并再次遇到相同的故事-没有自动填充功能,但可以识别对象。一切正常,我的主要任务-将复选框与LinkedCell区域对齐仅是几句话。

所以我的问题-为什么AutoFill / Intellisense不提供该选项-我应该添加对某些内容的引用还是仅仅是Excel中的一个小故障? 下面的代码。

Sub SetWidthAsLinkedCells()

    Dim sh As Shape
    Dim myCbx As CheckBox
    Dim wks As Worksheet
    Dim LinkedCell As Range

    Set wks = ActiveSheet
    For Each myCbx In wks.CheckBoxes
        Set LinkedCell = wks.Range(myCbx.LinkedCell)
        With myCbx
            .Top = LinkedCell.Top + 1
            .Left = LinkedCell.Left + 1
            .Width = LinkedCell.Width - 2
            .Height = LinkedCell.Height - 2
        End With

    Next myCbx

End Sub

0 个答案:

没有答案