excelvbamacosexcel-2011

Checkbox not working on mac


I wrote an excel VBA macro that works with checkboxes. To check whether the checkbox is selected or not I use the following code:

Sheet4.Shapes("dietary").OLEFormat.Object.Value

This works well on a windows PC; however, a colleague uses a mac and there it produces an error.

How can I use the checkboxes in a way that is compatible with windows and mac?


Solution

  • The problem is not with the Checkbox. It is with the way you are referencing the sheet :)

    Codenames sometimes give a problem in Excel 2011

    Try this

    ThisWorkbook.Sheets("Sheet4").Shapes("dietary").OLEFormat.Object.Value
    

    Example (Depicting Both Scenarios)

    enter image description here

    Now removing the CodeName

    enter image description here