+ Reply to Thread
Results 1 to 10 of 10

Multiple option buttons - Need VBA to disable second group of option buttns based on respo

  1. #1
    Registered User
    Join Date
    06-15-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    6

    Multiple option buttons - Need VBA to disable second group of option buttns based on respo

    Disable Option button.jpgDear All,

    I am creating a survey in Excel 2010, where I need to disable the second group of option buttons based on response given/clicked in first group of option buttons.

    What I want: If the user selects 'NA' radio/option button, assign its value as '0', and disable all corresponding options in the second group (option buttons 2).

    My worksheet looks like this ... (attached workbook)



    If only 'NA' is checked in Option buttons 1 then all corresponding options group 2 should get disabled, else user should be able to check/choose option in both groups of option buttons.

    I have already created the option groups but unable to disable based on selection in the first group)

    Unable to upload my workbook as file attachment in this forum.

    Thanks for reading and look for your help (VBA code) to above problem.
    Attached Files Attached Files
    Last edited by ex123; 06-19-2013 at 03:31 AM.

  2. #2
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Hi,

    it's all about the naming of the option buttons:
    'Naming convention (e.g. "OP_A1Q1R1C1"):Two sets of OptionButtons.xls
    'OP : optionbutton
    '_ : placeholder
    'A1 : attribute 1
    'Q1 : question 1
    'R1 : response 1
    'C1 : code 1

    Name your option buttons accordingly and assign all OP's from response 1 to the macro "OP_Click", it will dis-/enable the corresponding option buttons in response 2, change the back color of the cell and set the value to 0:

    contains:
    Please Login or Register  to view this content.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  3. #3
    Registered User
    Join Date
    06-15-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Dear tehneXus,

    Thanks for your reply. I tried running the macro, but getting run time vba error.

    My comlete workbook is attached for your reference. Please have a look, do you think it's possible.How can i make it work in my workbook, thanks again for your help.




    Quote Originally Posted by tehneXus View Post
    Hi,

    it's all about the naming of the option buttons:
    'Naming convention (e.g. "OP_A1Q1R1C1"):Attachment 243453
    'OP : optionbutton
    '_ : placeholder
    'A1 : attribute 1
    'Q1 : question 1
    'R1 : response 1
    'C1 : code 1

    Name your option buttons accordingly and assign all OP's from response 1 to the macro "OP_Click", it will dis-/enable the corresponding option buttons in response 2, change the back color of the cell and set the value to 0:

    contains:
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    1. Please do not quote entire posts, it makes the thread unreadable.

    2.
    Quote Originally Posted by ex123 View Post
    I tried running the macro, but getting run time vba error.
    You got the error in the example file? which error number in which line?

    3. I'll have a look at the complete file.

  5. #5
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    So,

    the following works fine for me for the first 2 questions: MultipleOptionButtons_Dis-Enable_Forum_post.xlsm

    Check the names of the OP buttons in the name box by right-clicking them, your part is to set the names of all the other OP buttons according to the naming convention in post #2 and assign the "Critically" buttons (1-4 and NA) to the macro "OP_Click()"

    If you still have the runtime error I will have a look again, as I said, I need the error number and the line in which the error occurs.

  6. #6
    Registered User
    Join Date
    06-15-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Thanks for your support. I am not getting any error, but it's not dis/enabling.

    Steps followed,
    1. Named all option buttons in response group 1 as per naming convention in post #2 (have I done correct?!)
    2. Assigned macro OP_Click() to all option buttons in response group 1

    There is no error while running macro, but options in response group 2 are not disabled when a question is marked 'NA'.

    For your reference, I am attaching my workbook. Let me know if I need to do few more settings....
    Last edited by ex123; 06-18-2013 at 03:58 AM.

  7. #7
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Hi,

    the names in response group 1 are assigned correctly, well done.

    Seems like I forgot to tell you to also set names for response group 2 so the code will identify the OP buttons by their name. The name for the next button in response group 2 question 3 code 1 will be "OP_A1Q3R2C1"

  8. #8
    Registered User
    Join Date
    06-15-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Completed the following steps,
    1. Named the option buttons in response group 2 as per the convention
    2. Save the file,

    Disable/enable is now working, except for row # 58, 61, 66, and 67. When I change the response in group 1 for these rows, it enables response group 2 buttons in previous row. Not able to figure-out what’s the problem? Have I named correctly? Updated workbook is attached for your review. Thanks a lot for your quick response.

  9. #9
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Hi,

    please check this: Multiple_OptionButtons_Dis-Enable_EXForum_post4.xlsm

    There was a problem with code as it was not able to handle question numbers of 2 digits. I renamed all OP's accordingly and adapted the code.
    Please note that for performance reasons there will only be 4 OP's changed in response 2, if you add one OP there you must adapt this in the code.

  10. #10
    Registered User
    Join Date
    06-15-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Multiple option buttons - Need VBA to disable second group of option buttns based on r

    Dear tehneXus,
    Thanks a lot for your help... I understand how tedious it is to rename all option buttons. Your code worked... and I learned something new.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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