+ Reply to Thread
Results 1 to 2 of 2

Auto Hide/Unhide rows in Excel based on radio button selection

  1. #1
    Registered User
    Join Date
    MS-Off Ver
    Excel 2010

    Auto Hide/Unhide rows in Excel based on radio button selection

    Let me start off by saying that I have ZERO experience with VBA. I have been searching for solutions to my request and have tried numerous different codes that I have found on this site with various success. The problem is that I can't adapt the code to work with my specific need.

    I have a questionnaire that I am designing. There are certain questions where a "No" answer should hide a few rows that follow the answer. I currently have it set-up with Option Button (Form Controls) to take the Yes or No answer. I have that linked to a cell and based off of that value a formula would determine which rows are hidden. For example, there are Yes/No option buttons in cell A1. Those buttons are linked to cell C1, so a click on "Yes" gives a value of 1 to cell C1 and a click on "No" gives a value of 2 in cell C1. If the user selects "No," I would like rows 2 and 3 to be hidden.

    I would like to continue to use the option buttons rather than validation because I like the look of it better (plus I have already created all the necessary option buttons in the questionnaire!). If it has to be done with validation, I wouldn't totally be against it.

    Any ideas on how I can get this to work?

    I appreciate any help that you can give!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010

    Re: Auto Hide/Unhide rows in Excel based on radio button selection

    Hi Awill,

    An event procedure should do the trick for you:

    Please Login or Register  to view this content.
    Directions for running the routine(s) just supplied

    Copy the code to the clipboard

    Save your Workbook As Macro-Enabled

    Press ALT + F11 to open the Visual Basic Editor.

    Select the Sheet where you have your buttons from the Insert menu

    Type "Option Explicit" then paste the code under it

    Then it should be easy sailing!
    Last edited by xladept; 03-30-2013 at 03:08 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

+ Reply to Thread

Thread Information

Users Browsing this Thread

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


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