Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding OptionButtons to the Userform programatically in VBA Excel
    primarykey
    data
    text
    <p>I am very new to VBA programming. My scenario is I will get a list of String values I need these values to be displayed to the user using radio buttons on a small window so that whenever the user selects any value by clicking on the radio button I should be able to get that value in the VBA code. I searched for adding options button in the user form in the internet I got some solution which use GUI method of creating option buttons. But I need it done through program. I found a helpful thread in stackoverflow (<a href="https://stackoverflow.com/questions/2049347/how-can-i-dynamically-add-a-radio-button-on-a-form-using-vba">How can I dynamically add a radio button on a form using VBA</a> ) I used this but still I am unable to get any label or button on the user form, a plain userform will be displayed. So anybody please give information regarding this. </p> <p>The code is : </p> <pre><code>Sub Button1_Click() lResult As Variant ' this is a array which contains string vaues to be dispayed as radio button. ' Some operatin is done here to get the list of values in lResult Dim rad As Variant Set rad = UserForm1.Controls.Add("Forms.OptionButton.1", "radioFoo", True) rad.Caption = "bar" rad.Left = 10 rad.Width = 10 rad.Top = 10 End Sub </code></pre> <p>UserForm1 is the userform which I created using Insert option in VBA menu bar. I tried to add a single button on the userform. I did not use initialize function on userform. There is button on excel sheet Button1 I am calling this function on clicking that button. </p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload