locked
Detecting triple state conditions RRS feed

  • Question

  • I want to have a triple state checkbox on a form to show if the cells in a selected range are locked, not locked or a mix. Clicking will either lock or unlock them all. i.e. it should behave exactly like the original in Excel's format|cells|protection.

    How do I code the initial detection? Do I need a "For each cell" loop and do something like count the trues and the falses then set the state of the checkbox based on the results?

    I can do that but is there another way? More elegant?

    Friday, February 17, 2012 4:41 PM

Answers

  • Easy:

    Me.chkLocked = Selection.Locked

    For a multi-cell range, the Locked property is True if all cells are locked, False if all cells are unlocked, and Null if there is a mixture - exactly the three values of a triple-state check box!


    Regards, Hans Vogelaar

    • Marked as answer by DiGiMac Tuesday, February 21, 2012 11:30 AM
    Friday, February 17, 2012 5:17 PM