是否可以返回Excel VBA中的复选框的名称? [英] Is it possible to return the names of checkboxes in Excel VBA?

查看:942
本文介绍了是否可以返回Excel VBA中的复选框的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用几个包含数百个复选框的工作表。这些复选框后面的代码工作正常,但我正在寻找一个方法来列出每列的复选框的名称,即我需要知道列G中所有复选框的名称,例如。

I'm currently working with a couple of worksheets that contain hundreds of checkboxes. The code behind these checkboxes works fine, but I'm looking for a way to list the names of the checkboxes per column, i.e. I need to know the names of all checkboxes in column G, for instance.

有人知道这是否可能吗?

Does anyone know if this is possible?

非常感谢!

推荐答案

请考虑使用TopLeftCell属性。

Consider using the TopLeftCell property

Sub ListCheckBoxes()

    Dim ole As OLEObject

    'Loop through all the active x controls
    For Each ole In Sheet1.OLEObjects
        'Only care about checkboxes
        If TypeName(ole.Object) = "CheckBox" Then
            'Check topleftcell property
            If ole.TopLeftCell.Column = Sheet1.Range("G1").Column Then
                'print out list
                Debug.Print ole.TopLeftCell.Address, ole.Name
            End If
        End If
    Next ole

End Sub

这篇关于是否可以返回Excel VBA中的复选框的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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