neilcsmith1984
New Member
- Joined
- May 25, 2020
- Messages
- 14
- Office Version
- 2013
- Platform
- Windows
Hi,
I have created the below VBA to hide rows depending on the value in A99, which works fine.
However, when the value in cell A99 changes to a higher value it hides the required rows, but does not unhide the rows above.
Is there any way to adjust the formula, to unhide the previous rows
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("Overview")
Thanks
If Target.Address = "$A$99" Then
If Target.Value = 1 Then Rows("102:119").EntireRow.Hidden = True
If Target.Value = 2 Then Rows("103:119").EntireRow.Hidden = True
If Target.Value = 3 Then Rows("104:119").EntireRow.Hidden = True
If Target.Value = 4 Then Rows("105:119").EntireRow.Hidden = True
If Target.Value = 5 Then Rows("106:119").EntireRow.Hidden = True
If Target.Value = 6 Then Rows("107:119").EntireRow.Hidden = True
If Target.Value = 7 Then Rows("108:119").EntireRow.Hidden = True
If Target.Value = 8 Then Rows("109:119").EntireRow.Hidden = True
If Target.Value = 9 Then Rows("110:119").EntireRow.Hidden = True
If Target.Value = 10 Then Rows("111:119").EntireRow.Hidden = True
If Target.Value = 11 Then Rows("112:119").EntireRow.Hidden = True
If Target.Value = 12 Then Rows("113:119").EntireRow.Hidden = True
If Target.Value = 13 Then Rows("114:119").EntireRow.Hidden = True
If Target.Value = 14 Then Rows("115:119").EntireRow.Hidden = True
If Target.Value = 15 Then Rows("116:119").EntireRow.Hidden = True
If Target.Value = 16 Then Rows("117:119").EntireRow.Hidden = True
If Target.Value = 17 Then Rows("118:119").EntireRow.Hidden = True
If Target.Value = 18 Then Rows("119:119").EntireRow.Hidden = True
If Target.Value > 18 Then Rows("102:119").EntireRow.Hidden = False
End If
End With
End Sub
I have created the below VBA to hide rows depending on the value in A99, which works fine.
However, when the value in cell A99 changes to a higher value it hides the required rows, but does not unhide the rows above.
Is there any way to adjust the formula, to unhide the previous rows
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("Overview")
Thanks
If Target.Address = "$A$99" Then
If Target.Value = 1 Then Rows("102:119").EntireRow.Hidden = True
If Target.Value = 2 Then Rows("103:119").EntireRow.Hidden = True
If Target.Value = 3 Then Rows("104:119").EntireRow.Hidden = True
If Target.Value = 4 Then Rows("105:119").EntireRow.Hidden = True
If Target.Value = 5 Then Rows("106:119").EntireRow.Hidden = True
If Target.Value = 6 Then Rows("107:119").EntireRow.Hidden = True
If Target.Value = 7 Then Rows("108:119").EntireRow.Hidden = True
If Target.Value = 8 Then Rows("109:119").EntireRow.Hidden = True
If Target.Value = 9 Then Rows("110:119").EntireRow.Hidden = True
If Target.Value = 10 Then Rows("111:119").EntireRow.Hidden = True
If Target.Value = 11 Then Rows("112:119").EntireRow.Hidden = True
If Target.Value = 12 Then Rows("113:119").EntireRow.Hidden = True
If Target.Value = 13 Then Rows("114:119").EntireRow.Hidden = True
If Target.Value = 14 Then Rows("115:119").EntireRow.Hidden = True
If Target.Value = 15 Then Rows("116:119").EntireRow.Hidden = True
If Target.Value = 16 Then Rows("117:119").EntireRow.Hidden = True
If Target.Value = 17 Then Rows("118:119").EntireRow.Hidden = True
If Target.Value = 18 Then Rows("119:119").EntireRow.Hidden = True
If Target.Value > 18 Then Rows("102:119").EntireRow.Hidden = False
End If
End With
End Sub