Results 1 to 8 of 8

Assign Radio Buttons in Excel User Form to a Group at Runtime

Threaded View

  1. #1
    Registered User
    Join Date
    12-21-2013
    Location
    Boston
    MS-Off Ver
    Microsoft 365 MSO (Version 2305 Build 16.0.16501.20074) 32-bit
    Posts
    6

    Assign Radio Buttons in Excel User Form to a Group at Runtime

    In the following vba code from Excel 365 I am creating a number of radio buttons. I cannot seem to assign them to a group for later use in code.
    I have tried using .Group and .OptionButtonGroup but neither come up in intellisense. Its like the Microsoft Forms 2.0 Object Library is not referenced, but it is. What am I missing?

    TIA.

    Private Sub AddProductLine()
    
    Dim optBtn As control
    Dim c As control
    Dim theTop, theWidth As Double
    Dim i As Integer
    Dim theProductList As Variant
    
    
    theProductList = GetProductNames '-----GETTING PRODUCT LINES FROM EXCEL SHEET theTop = 10 '-----SETTING TOP OF FIRST BUTTON IN FRAME theWidth = 50 '-----SETTING WIDTH OF ALL THE RADIO BUTTONS '-------------------ADDING THE RADIO BUTTONS TO THE FRAME PRODUCT LIST For i = 1 To UBound(theProductList) Set optBtn = ProductFrame.Controls.Add("Forms.OptionButton.1", theProductList(i, 1), True) With optBtn .Caption = theProductList(i, 1) .Width = theWidth .Top = theTop .Left = 12 End With theTop = theTop + 17.5 Next i ProductFrame.Height = theTop + 15 Me.Controls.Item("GAP").Value = True
    End Sub
    Last edited by AliGW; 06-27-2023 at 09:24 AM. Reason: Code tags added. Please read the forum rules.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to connect User Form Radio Button to Radio Buttons in Workbook
    By cameronadill in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2022, 07:43 AM
  2. [SOLVED] Assign macro to user form buttons
    By mia12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2021, 10:57 AM
  3. [SOLVED] Using Radio buttons and Check box on a user form
    By deek in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-18-2020, 12:48 PM
  4. [SOLVED] Add Command Buttons to User Form at Runtime
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 12-16-2013, 07:04 PM
  5. assign value to radio buttons
    By kaypat1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-09-2013, 06:49 PM
  6. How to insert and user of Buttons, Radio buttons, check boxes in excel sheet.
    By krishco in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 02:52 AM
  7. [SOLVED] How can I reset an Excel form that has radio buttons.
    By JaxPM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2006, 11:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1