I have code that refers to a checkbox control on a worksheet like this:
X = chkSRAP.Value
However, since that worksheet could potentially be deleted and cause problems in the future, I'd like to refer to the checkbox along these lines:
X = Sheets("SHRP Input").OLEObjects("chkSRAP").Value
Except this doesn't work. I get:
Run-time error '438':
Object doesn't support this property or method
Now, this sort of syntax seems to work for textboxes, comboboxes, toggle buttons and spinner controls. But not checkboxes.
EDIT: I tried recording a macro of me selecting the checkbox, and got this:
However, when I try:
X = Sheets("SHRP Input").Shapes.Range(Array("chkSRAP")).Value
I get the same error.
Any idea how I should alter my syntax so I can refer to the checkbox?