tlc53
Active Member
- Joined
- Jul 26, 2018
- Messages
- 399
Hi there,
I have a list of questions which are answered by Yes/No Option buttons. The option buttons are linked to the neighbouring cell and return value 1 if Yes, and 2 if No.
So the user can add a comment, I would like if No is selected (cell value is 2), then the row directly under it is unhidden. If Yes is selected (cell value is 1) or neither option button are selected yet (cell value 0) then the row directly under remains hidden.
I'm a little stumped as to how to set this VBA code out. Here is my not-so-good attempt but hopefully it shows what I am trying to do. The result to the questions go from "I14:I62" so tying to do it this way, I would need to repeat the code many more times still.
Any help with this would be much appreciated.
Thanks!
I have a list of questions which are answered by Yes/No Option buttons. The option buttons are linked to the neighbouring cell and return value 1 if Yes, and 2 if No.
So the user can add a comment, I would like if No is selected (cell value is 2), then the row directly under it is unhidden. If Yes is selected (cell value is 1) or neither option button are selected yet (cell value 0) then the row directly under remains hidden.
I'm a little stumped as to how to set this VBA code out. Here is my not-so-good attempt but hopefully it shows what I am trying to do. The result to the questions go from "I14:I62" so tying to do it this way, I would need to repeat the code many more times still.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("I14").Value = 2 Then
Range("I15").EntireRow.Hidden = False
Else
Range("I15").EntireRow.Hidden = True
End If
If Range("I16").Value = 2 Then
Range("I17").EntireRow.Hidden = False
Else
Range("I17").EntireRow.Hidden = True
End If
If Range("I18").Value = 2 Then
Range("I19").EntireRow.Hidden = False
Else
Range("I19").EntireRow.Hidden = True
End Sub
Any help with this would be much appreciated.
Thanks!