+ Reply to Thread
Results 1 to 8 of 8

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

  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.

    Please Login or Register  to view this content.
    Last edited by AliGW; 06-27-2023 at 09:24 AM. Reason: Code tags added. Please read the forum rules.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

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

    see big yellow banner - how to upload your workbook - far easier then to give you suitable in-context solution.
    Torachan,

    Mission statement; Promote the use of Tables, Outlaw the use of 'merged cells' and 'RowSource'.

  3. #3
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,928

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

    I have a feeling that grouping userform controls is a design aid and isn't available at runtime.
    An alternative is probably possible depending on what "for later use in code" means.

  4. #4
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

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

    The reason I requested a workbook was to be able to see the solution worked in-situ, however a year or two back I produced something similar that was expandable at run-time.
    It is based on block modules of ten questions, to expand the questionnaire form simply add another block of questions to the sheet/table by inserting above the summation row.
    Press the button and a second page is added to the multipage (it became an exercise in maths/algebra rather than coding) - this approach may be of some relevance to what you are trying to achieve.
    Attached Files Attached Files

  5. #5
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

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

    You can group them by specifying the GroupName property after you add each one. It's pretty odd to have different groups within the same frame though.
    Rory

  6. #6
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,928

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

    Can you reference the group in code or just the group property of the controls?

  7. #7
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,907

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

    The groupname only affects which ones can be true at the same time. There is no runtime equivalent of the design time grouping if you want to manipulate multiple controls at the same time. You'd either have to use a separate frame for each group, or use something like a collection/array and process each item the same way. It wasn't really clear to me what the OP was doing though.

  8. #8
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,303

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

    I have combined a simple runtime procedure with a class module to intercept the button choice, this may help visualise the choices made and may assist in coding I.D.
    Attached Files Attached Files

+ Reply to Thread

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