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?
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.
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]
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.
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks