Hi all,
I need to vba code to hide the row based on value in one cell. To illustrate, when the cell A29=1. I would like the row 55 to 103 to hide. When A29=2, I would like row 56 to 103 to hide so on and so forth till 50. The following code works for the first two, but as I add more code , the code fails to work. Wonder if anybody can help. Many thanks
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
I need to vba code to hide the row based on value in one cell. To illustrate, when the cell A29=1. I would like the row 55 to 103 to hide. When A29=2, I would like row 56 to 103 to hide so on and so forth till 50. The following code works for the first two, but as I add more code , the code fails to work. Wonder if anybody can help. Many thanks
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
- If Range("A29").Value = 1 Then
- Rows("55:103").EntireRow.Hidden = True
- Else
- Rows("55:103").EntireRow.Hidden = False
- End If
- If Range("A29").Value = 2 Then
- Rows("56:103").EntireRow.Hidden = True
- Else
- Rows("56:103").EntireRow.Hidden = False
- End If
- End Sub