ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to access a value from excel option button using visual basic? (https://www.excelbanter.com/excel-programming/324208-how-access-value-excel-option-button-using-visual-basic.html)

henry

how to access a value from excel option button using visual basic?
 
Hi,
my name is henry. I want to ask how to access a value in Excel option button
which is using xlformcontrol.xloptionbutton
which the value i want to show in textbox as information.

i've coding :
msgbox excel.xlformcontrol.xloptionbutton
and it displayed number 7 which the const of xloptionbutton
what i want is the value inside the optionbutton not the const.

does anyone know the answer?
thank's in advance

Bob Phillips[_6_]

how to access a value from excel option button using visual basic?
 
Msgbox Optionbutton1.Value

But it will show True or False, that is set or not.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"henry" wrote in message
m...
Hi,
my name is henry. I want to ask how to access a value in Excel option

button
which is using xlformcontrol.xloptionbutton
which the value i want to show in textbox as information.

i've coding :
msgbox excel.xlformcontrol.xloptionbutton
and it displayed number 7 which the const of xloptionbutton
what i want is the value inside the optionbutton not the const.

does anyone know the answer?
thank's in advance




Tushar Mehta

how to access a value from excel option button using visual basic?
 
Hi Henry,

What you are checking is just the value of the constant that XL uses to
identify the type of shape. For more search XL VBA help for
xlformcontrol and you will be led to the 'FormControlType Property'
page.

What you want to do is check the caption of the option button that the
user selected. Assuming you put multiple option buttons within a group
box in a worksheet, XL will ensure that only one of the option buttons
is selected at any given time. Then, you can use code like:

Dim i As Integer
With ActiveSheet
For i = 1 To .OptionButtons.Count
If .OptionButtons(i).Value = 1 Then
.Labels(1).Caption = .OptionButtons(i).Caption
End If
Next i
End With

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hi,
my name is henry. I want to ask how to access a value in Excel option button
which is using xlformcontrol.xloptionbutton
which the value i want to show in textbox as information.

i've coding :
msgbox excel.xlformcontrol.xloptionbutton
and it displayed number 7 which the const of xloptionbutton
what i want is the value inside the optionbutton not the const.

does anyone know the answer?
thank's in advance



All times are GMT +1. The time now is 01:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com