+ Reply to Thread
Results 1 to 4 of 4

Reference checkbox using linked cell address

  1. #1
    Registered User
    Join Date
    06-02-2011
    Location
    MI, US
    MS-Off Ver
    Excel 2003
    Posts
    2

    Reference checkbox using linked cell address

    Is there a way to reference a checkbox given the cell that the checkbox is located in/linked to?

    I do not have the checkbox name and do not want to iterate through the entire checkbox collection if I can help it?
    Last edited by chewie; 06-02-2011 at 02:13 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Reference checkbox using linked cell address

    Do you mean reference it in VBA code? Or in a formula in the Excel sheet?

    In either case, the linked cell contains the value TRUE or FALSE depending on the state of the checkbox, so you can certainly reference the linked cell.

    (Your description sounds otherwise a bit confusing. How would you know the cell it is linked to if you don't know the checkbox name?)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Reference checkbox using linked cell address

    I reread your question and my answer may not be sufficiently detailed.

    If you know a cell, and know that a checkbox is linked to that cell, you cannot work backwards to identify what checkbox is linked to it without iterating through all checkboxes. (The linked cell is an attribute of the checkbox, but a Range doesn't have an attribute that will tell you what links to it.)

    However, you can manipulate the linked cell without having to touch the checkbox. The value (TRUE or FALSE) will tell you the state of the checkbox, and a change to the other value will change the state of the checkbox.

  4. #4
    Registered User
    Join Date
    06-02-2011
    Location
    MI, US
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Reference checkbox using linked cell address

    Thanks for your posts. I am familiar with VBA but not very familiar with the form controls. I wanted to have two checkboxes that were related in that when the user clicked on one then the actions performed would differ if the other checkbox was selected or not.

    I had originally thought on the click event of one checkbox, I could navigate to the initially selected checkboxes' linked cell, offset to the cell containing the related checkbox and then check it's selected state to determine what actions to perform.

    However, I have since found the name property of the checkbox control and am naming all of the controls with names that are related and easily identifiable. Therefore, when a chcekbox is clicked I can deduce the name of the control I need to check by parsing the name of the selected checkbox and doing some string manipulation followed by a direct reference to the now identifiable and related checkbox.

    It works a treat.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1