ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Form Option Buttons and Combo Boxes in VBA (https://www.excelbanter.com/excel-programming/302913-form-option-buttons-combo-boxes-vba.html)

Newboy18

Form Option Buttons and Combo Boxes in VBA
 
My spreadsheet is using items from the Form toolbar like
Option Buttons and Combo Boxes, but I don't understand
how to address or control them in VBA.

Another user helped me to clear all Option Buttons:
Dim opt As OptionButton
For Each opt In ActiveSheet.OptionButtons
opt.Value = False
Next opt

This works fine but how do I address a specific Option
Button, if I right click it there is no Properties
option, or do I get it from the Name Box, if that is so I
still can't see it because the Name box is too small?

Please help with 2 examples:
What is the command to set an Option Box to True
What is the command to set a Combo Box to display some
text.


Bob Phillips[_6_]

Form Option Buttons and Combo Boxes in VBA
 
Activesheet.OptinButton s("Option Button 1").Value = xlOn

With ActiveSheet.DropDowns("Drop Down 1")
MsgBox .List(3)
End With

or

With ActiveSheet.DropDowns("Drop Down 1")
MsgBox .List(.ListIndex)
End With

to get the selected value

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Newboy18" wrote in message
...
My spreadsheet is using items from the Form toolbar like
Option Buttons and Combo Boxes, but I don't understand
how to address or control them in VBA.

Another user helped me to clear all Option Buttons:
Dim opt As OptionButton
For Each opt In ActiveSheet.OptionButtons
opt.Value = False
Next opt

This works fine but how do I address a specific Option
Button, if I right click it there is no Properties
option, or do I get it from the Name Box, if that is so I
still can't see it because the Name box is too small?

Please help with 2 examples:
What is the command to set an Option Box to True
What is the command to set a Combo Box to display some
text.





All times are GMT +1. The time now is 06:05 AM.

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