How to access Checkbox from VBA in Excel 2007

前端 未结 3 1927
暗喜
暗喜 2021-01-12 14:19

When adding a checkbox, how do you access the value from VBA?

  • In Excel 2007, on the Developer Ribbon
  • Insert, Form Controls, Checkbox
  • Rena
3条回答
  •  感动是毒
    2021-01-12 15:04

    For completeness, if you're using an ActiveX checkbox instead of a regular checkbox, the syntax is

    If Sheet1.Shapes("chkMyCheck").OLEFormat.Object.Object.Value Then 
    ...
    

    found using the Locals window and a variable set to the shape -

    Dim shp as Shape
    Set shp = Sheet1.Shapes("chkMyCheck")
    Stop
    

提交回复
热议问题