Show or hide rows based on a cell

Solved
charlo78 Posted messages 34 Status Member -  
charlo78 Posted messages 34 Status Member -
Hello,

I am a newbie in VBA programming. However, I need help for my work. I am creating a form that needs to be dynamic (questions should appear or disappear based on the answers).

Here is my case:

On the questionnaire tab, I have my question and checkboxes "form" that return a value "True" or "False" in my "responses" tab in cell B6.

If B6 is True on my "responses" tab, I would like rows 60 to 97 of my "questionnaire" tab to be hidden.

If someone could help me by providing the programming, that would be really nice!

Thank you!

1 answer

  1. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717
     
    Hello,

    Code to put into a module and assign the macro to the checkbox by adapting the number

    'Checkbox 1 Sub Checkbox1_Click() If ActiveSheet.Shapes("Checkbox 1").OLEFormat.Object.Value = 1 Then Worksheets("Questionnaire").Rows("60:97").EntireRow.Hidden = True Else Worksheets("Questionnaire").Rows("60:97").EntireRow.Hidden = False End If End Sub 
    0
    1. charlo78 Posted messages 34 Status Member
       
      Thank you very much. It works! However, if I want to add a new conditional zone following this macro, what code should I write before copying and pasting your code, adapting the checkbox numbers and the rows to show/hide?

      Basically, my first 3 buttons make the described area appear, my buttons 4 and 5 make another area appear, and buttons 5 and 6 another one again.

      Thank you.
      0
    2. charlo78 Posted messages 34 Status Member
       
      And how do I proceed if the area I want to display is located between two areas that need to be masked?
      0
    3. f894009 Posted messages 17417 Registration date   Status Member Last intervention   1 717 > charlo78 Posted messages 34 Status Member
       
      Re,

      If you know the lines to show/hide, I don't see the difficulty!!

      An area between two hidden areas: the same, it's not more difficult than that!!
      0
    4. charlo78 Posted messages 34 Status Member
       
      I'm sorry, it's my first time coding.
      0
    5. charlo78 Posted messages 34 Status Member
       
      Thank you anyway, I will try to feel my way.
      0