control toolbox vs forms toolbars

S

Sasa Stankovic

Hi,
I have BIG issue!
On Sheet1 I have 2 OptionButton's (OptionButton1 and OptionButton2, as name
box shows me).
Problem is in the fact that they are from Control toolbox and they are not
linked to any cell or variable.
I need to check which one is selected!
I do now the procedure when working with Forms toolbar but how to work with
OptionButton from control toolbox which is placed on sheet?!?!
Any idea?

for example:
If [OptionButton1] = true then
' write something in cell AV6
Else
' write something else in cell AV6
EndIf

of course, this is not working...

please, anyone.....
 
L

Leith Ross

Hello Sasa Stankovic,

The easiest and quickest solution would be remove the Control Toolbox
Option Buttons and replace them with the Forms Option Buttons. If you
can't replace the buttons, here is how to check...

Code:
--------------------

Sub CheckOptionButtons()

Dim OleObj As Object
Dim OptBtn As Object

With ActiveSheet
For Each OleObj In .OLEObjects
If TypeName(OleObj.Object) = "OptionButton" Then
Set OptBtn = OleObj.Object
If OptBtn = True Then
MsgBox OleObj.Name & " is Set."
End If
End If
Next OleObj
End With

End Sub
 
D

Dave Peterson

If Worksheets("Sheet1").optionbutton1.Value = true then
worksheets("Sheet1").range("av6") = "hi"
else
worksheets("Sheet1").range("av6") = "bye"
end if



Sasa said:
Hi,
I have BIG issue!
On Sheet1 I have 2 OptionButton's (OptionButton1 and OptionButton2, as name
box shows me).
Problem is in the fact that they are from Control toolbox and they are not
linked to any cell or variable.
I need to check which one is selected!
I do now the procedure when working with Forms toolbar but how to work with
OptionButton from control toolbox which is placed on sheet?!?!
Any idea?

for example:
If [OptionButton1] = true then
' write something in cell AV6
Else
' write something else in cell AV6
EndIf

of course, this is not working...

please, anyone.....
 
S

Sasa Stankovic

Your soution works perfectly....
I was near but not close enough...

THANK YOU one more time!
 

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