View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Application.Caller syntax for worksheets?

You could have used optionbuttons from the Forms Toolbar or optionbuttons from
the Control toolbox toolbar on your worksheet.

It sounds like you used the optionbuttons from the Forms toolbar.

dim myOptBtn as optionbutton
for each myOptBtn in activesheet.optionbuttons
if myoptbtn.value = xlon then
msgbox myoptbtn.caption
exit for
end if
next myoptbtn

Just in case they were from the Control toolbox toolbar:

Dim OLEObj As OLEObject
For Each OLEObj In ActiveSheet.OLEObjects
If TypeOf OLEObj.Object Is MSForms.OptionButton Then
If OLEObj.Object.Value = True Then
MsgBox OLEObj.Object.Caption
Exit For
End If
End If
Next OLEObj


Ouka wrote:

Norman - Changing "true" to "xlOn" did not work, getting the same error.

Dave - the option buttons and the command buttons are all on a
worksheet, not a user form.

The command button is built at design time, but the option buttons are
built by the user at run time, hence I cannot know what they are going
to be named ahead of time for any "if optionbutton1.value = true then"
code.

I need VBA to return to me the name of selected option button so I can
assign that name as a variable to use in a calling procedure in my
code.

--
Ouka
------------------------------------------------------------------------
Ouka's Profile: http://www.excelforum.com/member.php...o&userid=23988
View this thread: http://www.excelforum.com/showthread...hreadid=502311


--

Dave Peterson