how do I set up if an answer is No then following row is hidden

A

AP

I am trying to create a form wherby if the answer to say Q1 is no then I need
to make the following rows in that section hidden
 
O

Otto Moehrbach

You would need VBA for that. Post back with more detail about what you have
and what rows you want hidden when what question gets a Yes/No. HTH Otto
 
A

Anne

thank you, but I'm not sure how to explain it. I'll try:
1st row has a heading with yes/no answer in next column. Dependant upon the
answer is whether or not the next rows are applicable. If the answer is no
then the next wouldn't be applicable and need to be hidden to enable the
person to continue with the next question etc.
 
F

Fred Smith

You'll need to provide more details. Try providing specific example, as in:

I have a heading in row 1. In cell c1, there is "yes" or "no". If c1 is "no", I
need to hide row 2.

Given this kind of detail, you'll have no problem getting someone to show you
the code required.
 
A

Anne

Fred,

The heading is in C19 and the yes/no box is in G19 - if G19 is "no" then I
need to hide row 20. It would then go to C21 and if the answer in G21 was
"no" I would need to hide rows 22-25.

Regards
Anne
 
O

Otto Moehrbach

Anne
I take it that you want this to happen at the time that the user enters
a "No" in the Column G cell. I'll also assume that all this is applicable
to all Column G cells from Row 5 to Row 1000. You can change these things
in the macro below. Note that the case of the "No" that is entered does not
matter.
Note that this macro is a sheet macro and must be placed in the sheet module
of the sheet in which are doing the "No" thing. To access that module,
right click on the sheet tab, select View Code, and paste this macro into
that module. Click on the "X" at the top right of the module to return to
your sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
If IsEmpty(Target.Value) Then Exit Sub
If Target.Column = 7 And _
Target.Row >= 5 And _
Target.Row <= 1000 And _
UCase(Target.Value) = "NO" Then _
Target.Offset(1).EntireRow.Hidden = True
End Sub
 
O

Otto Moehrbach

Anne
Ignore the response and macro I just gave you. I reread your last post
and just now realized that the number of rows to be hidden varies with the
Column G cell that received the "No". So I need to get more info from you.
I need a list of the pertinent Column G cells (the cells that could get
a "No") and the number of rows you want hidden for each Column G cell.
Something like :
G19 1
G21 4
G26 2
Etc.
Otto
 
O

Otto Moehrbach

Anne
I'll be out of town 29 Mar - 2 Apr and will work on this during that
time. But I will not have access to the newsgroup, so if you wish, email
the list I asked for and I'll respond to you via email or after I get back.
My email address is [email protected]. Remove the "nop" from this
address.
Otherwise I'll respond again when I get back. Otto
 
A

Anne

Otto has been incredibly helpful, I couldn't have asked for better help.
He's really good at this. Thank you
 
Top