Run-time 438 - OptionButton troubles

L

Luke

I've had this trouble in various different bits of code and can't figure out
how to correct it. Here's the situation:

I've selected an item from a ListBox contained within a UserForm. The
UserForm appears on sheet "A". Once I select the item, Excel gets busy
populating a whole bunch of stuff on sheet "B". In the process it is
supposed to check to see if the value of OptionButton1 on sheet "B" is
"True". The bit of code that it has trouble with is this:
If Worksheets("B").Shapes("OptionButton1").Value = True Then
' do stuff

At first, I had "OLEObjects" in the place of "Shapes", but it didn't like
that either. How do I go about checking the value of an ActiveX control
embedded on a worksheet, regardless of whether the worksheet is active?
 
L

Luke

I forgot to say, the error it is giving me says "Object doesn't support this
property or method".

Thanks.
 
D

Dave Peterson

I'd try:

If Worksheets("B").OptionButton1.Value = True Then

or if you want to use the OLEObjects collection:

If Worksheets("B").oleobjects("OptionButton1").object.Value = True Then
 
L

Luke

I had tried the first suggestion before, but to no avail. However, your
second suggestion worked like a charm. Thank you so much. This will save me
no end of headaches.
 
D

Dave Peterson

Both worked ok for me.

I had tried the first suggestion before, but to no avail. However, your
second suggestion worked like a charm. Thank you so much. This will save me
no end of headaches.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top