Simplify VBA code

Ibis2653

New Member
Joined
Aug 2, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I have been trying to find a way to simplify this VBA code as it takes a little while to run currently. I want it to automatically unhide row 7 on sheet 07 through sheet 32 when cell J4 on the active sheet is higher than 0 and if it is 0 or less then hide the row on those sheets. then repeat for row 8 and J5 row 9 and J6 etc


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$J$4" Then
        If Sheet02.Range("J4").Value <= 0 Then
            Sheet07.Rows("7:7").EntireRow.Hidden = True
            Sheet08.Rows("7:7").EntireRow.Hidden = True
            Sheet09.Rows("7:7").EntireRow.Hidden = True
            Sheet10.Rows("7:7").EntireRow.Hidden = True
            Sheet11.Rows("7:7").EntireRow.Hidden = True
            Sheet12.Rows("7:7").EntireRow.Hidden = True
            Sheet13.Rows("7:7").EntireRow.Hidden = True
            Sheet14.Rows("7:7").EntireRow.Hidden = True
            Sheet15.Rows("7:7").EntireRow.Hidden = True
            Sheet16.Rows("7:7").EntireRow.Hidden = True
            Sheet17.Rows("7:7").EntireRow.Hidden = True
            Sheet18.Rows("7:7").EntireRow.Hidden = True
            Sheet19.Rows("7:7").EntireRow.Hidden = True
            Sheet20.Rows("7:7").EntireRow.Hidden = True
            Sheet21.Rows("7:7").EntireRow.Hidden = True
            Sheet22.Rows("7:7").EntireRow.Hidden = True
            Sheet23.Rows("7:7").EntireRow.Hidden = True
            Sheet24.Rows("7:7").EntireRow.Hidden = True
            Sheet25.Rows("7:7").EntireRow.Hidden = True
            Sheet26.Rows("7:7").EntireRow.Hidden = True
            Sheet27.Rows("7:7").EntireRow.Hidden = True
            Sheet28.Rows("7:7").EntireRow.Hidden = True
            Sheet29.Rows("7:7").EntireRow.Hidden = True
            Sheet30.Rows("7:7").EntireRow.Hidden = True
            Sheet31.Rows("7:7").EntireRow.Hidden = True
            Sheet32.Rows("7:7").EntireRow.Hidden = True
        Else
            Sheet07.Rows("7:7").EntireRow.Hidden = False
            Sheet08.Rows("7:7").EntireRow.Hidden = False
            Sheet09.Rows("7:7").EntireRow.Hidden = False
            Sheet10.Rows("7:7").EntireRow.Hidden = False
            Sheet11.Rows("7:7").EntireRow.Hidden = False
            Sheet12.Rows("7:7").EntireRow.Hidden = False
            Sheet13.Rows("7:7").EntireRow.Hidden = False
            Sheet14.Rows("7:7").EntireRow.Hidden = False
            Sheet15.Rows("7:7").EntireRow.Hidden = False
            Sheet16.Rows("7:7").EntireRow.Hidden = False
            Sheet17.Rows("7:7").EntireRow.Hidden = False
            Sheet18.Rows("7:7").EntireRow.Hidden = False
            Sheet19.Rows("7:7").EntireRow.Hidden = False
            Sheet20.Rows("7:7").EntireRow.Hidden = False
            Sheet21.Rows("7:7").EntireRow.Hidden = False
            Sheet22.Rows("7:7").EntireRow.Hidden = False
            Sheet23.Rows("7:7").EntireRow.Hidden = False
            Sheet24.Rows("7:7").EntireRow.Hidden = False
            Sheet25.Rows("7:7").EntireRow.Hidden = False
            Sheet26.Rows("7:7").EntireRow.Hidden = False
            Sheet27.Rows("7:7").EntireRow.Hidden = False
            Sheet28.Rows("7:7").EntireRow.Hidden = False
            Sheet29.Rows("7:7").EntireRow.Hidden = False
            Sheet30.Rows("7:7").EntireRow.Hidden = False
            Sheet31.Rows("7:7").EntireRow.Hidden = False
            Sheet32.Rows("7:7").EntireRow.Hidden = False
        End If
    End If
       
    If Target.Address = "$J$5" Then
        If Sheet02.Range("J5").Value <= 0 Then
            Sheet07.Rows("8:8").EntireRow.Hidden = True
            Sheet08.Rows("8:8").EntireRow.Hidden = True
            Sheet09.Rows("8:8").EntireRow.Hidden = True
            Sheet10.Rows("8:8").EntireRow.Hidden = True
            Sheet11.Rows("8:8").EntireRow.Hidden = True
            Sheet12.Rows("8:8").EntireRow.Hidden = True
            Sheet13.Rows("8:8").EntireRow.Hidden = True
            Sheet14.Rows("8:8").EntireRow.Hidden = True
            Sheet15.Rows("8:8").EntireRow.Hidden = True
            Sheet16.Rows("8:8").EntireRow.Hidden = True
            Sheet17.Rows("8:8").EntireRow.Hidden = True
            Sheet18.Rows("8:8").EntireRow.Hidden = True
            Sheet19.Rows("8:8").EntireRow.Hidden = True
            Sheet20.Rows("8:8").EntireRow.Hidden = True
            Sheet21.Rows("8:8").EntireRow.Hidden = True
            Sheet22.Rows("8:8").EntireRow.Hidden = True
            Sheet23.Rows("8:8").EntireRow.Hidden = True
            Sheet24.Rows("8:8").EntireRow.Hidden = True
            Sheet25.Rows("8:8").EntireRow.Hidden = True
            Sheet26.Rows("8:8").EntireRow.Hidden = True
            Sheet27.Rows("8:8").EntireRow.Hidden = True
            Sheet28.Rows("8:8").EntireRow.Hidden = True
            Sheet29.Rows("8:8").EntireRow.Hidden = True
            Sheet30.Rows("8:8").EntireRow.Hidden = True
            Sheet31.Rows("8:8").EntireRow.Hidden = True
            Sheet32.Rows("8:8").EntireRow.Hidden = True
        Else
            Sheet07.Rows("8:8").EntireRow.Hidden = False
            Sheet08.Rows("8:8").EntireRow.Hidden = False
            Sheet09.Rows("8:8").EntireRow.Hidden = False
            Sheet10.Rows("8:8").EntireRow.Hidden = False
            Sheet11.Rows("8:8").EntireRow.Hidden = False
            Sheet12.Rows("8:8").EntireRow.Hidden = False
            Sheet13.Rows("8:8").EntireRow.Hidden = False
            Sheet14.Rows("8:8").EntireRow.Hidden = False
            Sheet15.Rows("8:8").EntireRow.Hidden = False
            Sheet16.Rows("8:8").EntireRow.Hidden = False
            Sheet17.Rows("8:8").EntireRow.Hidden = False
            Sheet18.Rows("8:8").EntireRow.Hidden = False
            Sheet19.Rows("8:8").EntireRow.Hidden = False
            Sheet20.Rows("8:8").EntireRow.Hidden = False
            Sheet21.Rows("8:8").EntireRow.Hidden = False
            Sheet22.Rows("8:8").EntireRow.Hidden = False
            Sheet23.Rows("8:8").EntireRow.Hidden = False
            Sheet24.Rows("8:8").EntireRow.Hidden = False
            Sheet25.Rows("8:8").EntireRow.Hidden = False
            Sheet26.Rows("8:8").EntireRow.Hidden = False
            Sheet27.Rows("8:8").EntireRow.Hidden = False
            Sheet28.Rows("8:8").EntireRow.Hidden = False
            Sheet29.Rows("8:8").EntireRow.Hidden = False
            Sheet30.Rows("8:8").EntireRow.Hidden = False
            Sheet31.Rows("8:8").EntireRow.Hidden = False
            Sheet32.Rows("8:8").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$6" Then
        If Sheet02.Range("J6").Value <= 0 Then
            Sheet07.Rows("9:9").EntireRow.Hidden = True
            Sheet08.Rows("9:9").EntireRow.Hidden = True
            Sheet09.Rows("9:9").EntireRow.Hidden = True
            Sheet10.Rows("9:9").EntireRow.Hidden = True
            Sheet11.Rows("9:9").EntireRow.Hidden = True
            Sheet12.Rows("9:9").EntireRow.Hidden = True
            Sheet13.Rows("9:9").EntireRow.Hidden = True
            Sheet14.Rows("9:9").EntireRow.Hidden = True
            Sheet15.Rows("9:9").EntireRow.Hidden = True
            Sheet16.Rows("9:9").EntireRow.Hidden = True
            Sheet17.Rows("9:9").EntireRow.Hidden = True
            Sheet18.Rows("9:9").EntireRow.Hidden = True
            Sheet19.Rows("9:9").EntireRow.Hidden = True
            Sheet20.Rows("9:9").EntireRow.Hidden = True
            Sheet21.Rows("9:9").EntireRow.Hidden = True
            Sheet22.Rows("9:9").EntireRow.Hidden = True
            Sheet23.Rows("9:9").EntireRow.Hidden = True
            Sheet24.Rows("9:9").EntireRow.Hidden = True
            Sheet25.Rows("9:9").EntireRow.Hidden = True
            Sheet26.Rows("9:9").EntireRow.Hidden = True
            Sheet27.Rows("9:9").EntireRow.Hidden = True
            Sheet28.Rows("9:9").EntireRow.Hidden = True
            Sheet29.Rows("9:9").EntireRow.Hidden = True
            Sheet30.Rows("9:9").EntireRow.Hidden = True
            Sheet31.Rows("9:9").EntireRow.Hidden = True
            Sheet32.Rows("9:9").EntireRow.Hidden = True
        Else
            Sheet07.Rows("9:9").EntireRow.Hidden = False
            Sheet08.Rows("9:9").EntireRow.Hidden = False
            Sheet09.Rows("9:9").EntireRow.Hidden = False
            Sheet10.Rows("9:9").EntireRow.Hidden = False
            Sheet11.Rows("9:9").EntireRow.Hidden = False
            Sheet12.Rows("9:9").EntireRow.Hidden = False
            Sheet13.Rows("9:9").EntireRow.Hidden = False
            Sheet14.Rows("9:9").EntireRow.Hidden = False
            Sheet15.Rows("9:9").EntireRow.Hidden = False
            Sheet16.Rows("9:9").EntireRow.Hidden = False
            Sheet17.Rows("9:9").EntireRow.Hidden = False
            Sheet18.Rows("9:9").EntireRow.Hidden = False
            Sheet19.Rows("9:9").EntireRow.Hidden = False
            Sheet20.Rows("9:9").EntireRow.Hidden = False
            Sheet21.Rows("9:9").EntireRow.Hidden = False
            Sheet22.Rows("9:9").EntireRow.Hidden = False
            Sheet23.Rows("9:9").EntireRow.Hidden = False
            Sheet24.Rows("9:9").EntireRow.Hidden = False
            Sheet25.Rows("9:9").EntireRow.Hidden = False
            Sheet26.Rows("9:9").EntireRow.Hidden = False
            Sheet27.Rows("9:9").EntireRow.Hidden = False
            Sheet28.Rows("9:9").EntireRow.Hidden = False
            Sheet29.Rows("9:9").EntireRow.Hidden = False
            Sheet30.Rows("9:9").EntireRow.Hidden = False
            Sheet31.Rows("9:9").EntireRow.Hidden = False
            Sheet32.Rows("9:9").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$7" Then
        If Sheet02.Range("J7").Value <= 0 Then
            Sheet07.Rows("10:10").EntireRow.Hidden = True
            Sheet08.Rows("10:10").EntireRow.Hidden = True
            Sheet09.Rows("10:10").EntireRow.Hidden = True
            Sheet10.Rows("10:10").EntireRow.Hidden = True
            Sheet11.Rows("10:10").EntireRow.Hidden = True
            Sheet12.Rows("10:10").EntireRow.Hidden = True
            Sheet13.Rows("10:10").EntireRow.Hidden = True
            Sheet14.Rows("10:10").EntireRow.Hidden = True
            Sheet15.Rows("10:10").EntireRow.Hidden = True
            Sheet16.Rows("10:10").EntireRow.Hidden = True
            Sheet17.Rows("10:10").EntireRow.Hidden = True
            Sheet18.Rows("10:10").EntireRow.Hidden = True
            Sheet19.Rows("10:10").EntireRow.Hidden = True
            Sheet20.Rows("10:10").EntireRow.Hidden = True
            Sheet21.Rows("10:10").EntireRow.Hidden = True
            Sheet22.Rows("10:10").EntireRow.Hidden = True
            Sheet23.Rows("10:10").EntireRow.Hidden = True
            Sheet24.Rows("10:10").EntireRow.Hidden = True
            Sheet25.Rows("10:10").EntireRow.Hidden = True
            Sheet26.Rows("10:10").EntireRow.Hidden = True
            Sheet27.Rows("10:10").EntireRow.Hidden = True
            Sheet28.Rows("10:10").EntireRow.Hidden = True
            Sheet29.Rows("10:10").EntireRow.Hidden = True
            Sheet30.Rows("10:10").EntireRow.Hidden = True
            Sheet31.Rows("10:10").EntireRow.Hidden = True
            Sheet32.Rows("10:10").EntireRow.Hidden = True
        Else
            Sheet07.Rows("10:10").EntireRow.Hidden = False
            Sheet08.Rows("10:10").EntireRow.Hidden = False
            Sheet09.Rows("10:10").EntireRow.Hidden = False
            Sheet10.Rows("10:10").EntireRow.Hidden = False
            Sheet11.Rows("10:10").EntireRow.Hidden = False
            Sheet12.Rows("10:10").EntireRow.Hidden = False
            Sheet13.Rows("10:10").EntireRow.Hidden = False
            Sheet14.Rows("10:10").EntireRow.Hidden = False
            Sheet15.Rows("10:10").EntireRow.Hidden = False
            Sheet16.Rows("10:10").EntireRow.Hidden = False
            Sheet17.Rows("10:10").EntireRow.Hidden = False
            Sheet18.Rows("10:10").EntireRow.Hidden = False
            Sheet19.Rows("10:10").EntireRow.Hidden = False
            Sheet20.Rows("10:10").EntireRow.Hidden = False
            Sheet21.Rows("10:10").EntireRow.Hidden = False
            Sheet22.Rows("10:10").EntireRow.Hidden = False
            Sheet23.Rows("10:10").EntireRow.Hidden = False
            Sheet24.Rows("10:10").EntireRow.Hidden = False
            Sheet25.Rows("10:10").EntireRow.Hidden = False
            Sheet26.Rows("10:10").EntireRow.Hidden = False
            Sheet27.Rows("10:10").EntireRow.Hidden = False
            Sheet28.Rows("10:10").EntireRow.Hidden = False
            Sheet29.Rows("10:10").EntireRow.Hidden = False
            Sheet30.Rows("10:10").EntireRow.Hidden = False
            Sheet31.Rows("10:10").EntireRow.Hidden = False
            Sheet32.Rows("10:10").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$8" Then
        If Sheet02.Range("J8").Value <= 0 Then
            Sheet07.Rows("11:11").EntireRow.Hidden = True
            Sheet08.Rows("11:11").EntireRow.Hidden = True
            Sheet09.Rows("11:11").EntireRow.Hidden = True
            Sheet10.Rows("11:11").EntireRow.Hidden = True
            Sheet11.Rows("11:11").EntireRow.Hidden = True
            Sheet12.Rows("11:11").EntireRow.Hidden = True
            Sheet13.Rows("11:11").EntireRow.Hidden = True
            Sheet14.Rows("11:11").EntireRow.Hidden = True
            Sheet15.Rows("11:11").EntireRow.Hidden = True
            Sheet16.Rows("11:11").EntireRow.Hidden = True
            Sheet17.Rows("11:11").EntireRow.Hidden = True
            Sheet18.Rows("11:11").EntireRow.Hidden = True
            Sheet19.Rows("11:11").EntireRow.Hidden = True
            Sheet20.Rows("11:11").EntireRow.Hidden = True
            Sheet21.Rows("11:11").EntireRow.Hidden = True
            Sheet22.Rows("11:11").EntireRow.Hidden = True
            Sheet23.Rows("11:11").EntireRow.Hidden = True
            Sheet24.Rows("11:11").EntireRow.Hidden = True
            Sheet25.Rows("11:11").EntireRow.Hidden = True
            Sheet26.Rows("11:11").EntireRow.Hidden = True
            Sheet27.Rows("11:11").EntireRow.Hidden = True
            Sheet28.Rows("11:11").EntireRow.Hidden = True
            Sheet29.Rows("11:11").EntireRow.Hidden = True
            Sheet30.Rows("11:11").EntireRow.Hidden = True
            Sheet31.Rows("11:11").EntireRow.Hidden = True
            Sheet32.Rows("11:11").EntireRow.Hidden = True
        Else
            Sheet07.Rows("11:11").EntireRow.Hidden = False
            Sheet08.Rows("11:11").EntireRow.Hidden = False
            Sheet09.Rows("11:11").EntireRow.Hidden = False
            Sheet10.Rows("11:11").EntireRow.Hidden = False
            Sheet11.Rows("11:11").EntireRow.Hidden = False
            Sheet12.Rows("11:11").EntireRow.Hidden = False
            Sheet13.Rows("11:11").EntireRow.Hidden = False
            Sheet14.Rows("11:11").EntireRow.Hidden = False
            Sheet15.Rows("11:11").EntireRow.Hidden = False
            Sheet16.Rows("11:11").EntireRow.Hidden = False
            Sheet17.Rows("11:11").EntireRow.Hidden = False
            Sheet18.Rows("11:11").EntireRow.Hidden = False
            Sheet19.Rows("11:11").EntireRow.Hidden = False
            Sheet20.Rows("11:11").EntireRow.Hidden = False
            Sheet21.Rows("11:11").EntireRow.Hidden = False
            Sheet22.Rows("11:11").EntireRow.Hidden = False
            Sheet23.Rows("11:11").EntireRow.Hidden = False
            Sheet24.Rows("11:11").EntireRow.Hidden = False
            Sheet25.Rows("11:11").EntireRow.Hidden = False
            Sheet26.Rows("11:11").EntireRow.Hidden = False
            Sheet27.Rows("11:11").EntireRow.Hidden = False
            Sheet28.Rows("11:11").EntireRow.Hidden = False
            Sheet29.Rows("11:11").EntireRow.Hidden = False
            Sheet30.Rows("11:11").EntireRow.Hidden = False
            Sheet31.Rows("11:11").EntireRow.Hidden = False
            Sheet32.Rows("11:11").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$9" Then
        If Sheet02.Range("J9").Value <= 0 Then
            Sheet07.Rows("12:12").EntireRow.Hidden = True
            Sheet08.Rows("12:12").EntireRow.Hidden = True
            Sheet09.Rows("12:12").EntireRow.Hidden = True
            Sheet10.Rows("12:12").EntireRow.Hidden = True
            Sheet11.Rows("12:12").EntireRow.Hidden = True
            Sheet12.Rows("12:12").EntireRow.Hidden = True
            Sheet13.Rows("12:12").EntireRow.Hidden = True
            Sheet14.Rows("12:12").EntireRow.Hidden = True
            Sheet15.Rows("12:12").EntireRow.Hidden = True
            Sheet16.Rows("12:12").EntireRow.Hidden = True
            Sheet17.Rows("12:12").EntireRow.Hidden = True
            Sheet18.Rows("12:12").EntireRow.Hidden = True
            Sheet19.Rows("12:12").EntireRow.Hidden = True
            Sheet20.Rows("12:12").EntireRow.Hidden = True
            Sheet21.Rows("12:12").EntireRow.Hidden = True
            Sheet22.Rows("12:12").EntireRow.Hidden = True
            Sheet23.Rows("12:12").EntireRow.Hidden = True
            Sheet24.Rows("12:12").EntireRow.Hidden = True
            Sheet25.Rows("12:12").EntireRow.Hidden = True
            Sheet26.Rows("12:12").EntireRow.Hidden = True
            Sheet27.Rows("12:12").EntireRow.Hidden = True
            Sheet28.Rows("12:12").EntireRow.Hidden = True
            Sheet29.Rows("12:12").EntireRow.Hidden = True
            Sheet30.Rows("12:12").EntireRow.Hidden = True
            Sheet31.Rows("12:12").EntireRow.Hidden = True
            Sheet32.Rows("12:12").EntireRow.Hidden = True
        Else
            Sheet07.Rows("12:12").EntireRow.Hidden = False
            Sheet08.Rows("12:12").EntireRow.Hidden = False
            Sheet09.Rows("12:12").EntireRow.Hidden = False
            Sheet10.Rows("12:12").EntireRow.Hidden = False
            Sheet11.Rows("12:12").EntireRow.Hidden = False
            Sheet12.Rows("12:12").EntireRow.Hidden = False
            Sheet13.Rows("12:12").EntireRow.Hidden = False
            Sheet14.Rows("12:12").EntireRow.Hidden = False
            Sheet15.Rows("12:12").EntireRow.Hidden = False
            Sheet16.Rows("12:12").EntireRow.Hidden = False
            Sheet17.Rows("12:12").EntireRow.Hidden = False
            Sheet18.Rows("12:12").EntireRow.Hidden = False
            Sheet19.Rows("12:12").EntireRow.Hidden = False
            Sheet20.Rows("12:12").EntireRow.Hidden = False
            Sheet21.Rows("12:12").EntireRow.Hidden = False
            Sheet22.Rows("12:12").EntireRow.Hidden = False
            Sheet23.Rows("12:12").EntireRow.Hidden = False
            Sheet24.Rows("12:12").EntireRow.Hidden = False
            Sheet25.Rows("12:12").EntireRow.Hidden = False
            Sheet26.Rows("12:12").EntireRow.Hidden = False
            Sheet27.Rows("12:12").EntireRow.Hidden = False
            Sheet28.Rows("12:12").EntireRow.Hidden = False
            Sheet29.Rows("12:12").EntireRow.Hidden = False
            Sheet30.Rows("12:12").EntireRow.Hidden = False
            Sheet31.Rows("12:12").EntireRow.Hidden = False
            Sheet32.Rows("12:12").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$10" Then
        If Sheet02.Range("J10").Value <= 0 Then
            Sheet07.Rows("13:13").EntireRow.Hidden = True
            Sheet08.Rows("13:13").EntireRow.Hidden = True
            Sheet09.Rows("13:13").EntireRow.Hidden = True
            Sheet10.Rows("13:13").EntireRow.Hidden = True
            Sheet11.Rows("13:13").EntireRow.Hidden = True
            Sheet12.Rows("13:13").EntireRow.Hidden = True
            Sheet13.Rows("13:13").EntireRow.Hidden = True
            Sheet14.Rows("13:13").EntireRow.Hidden = True
            Sheet15.Rows("13:13").EntireRow.Hidden = True
            Sheet16.Rows("13:13").EntireRow.Hidden = True
            Sheet17.Rows("13:13").EntireRow.Hidden = True
            Sheet18.Rows("13:13").EntireRow.Hidden = True
            Sheet19.Rows("13:13").EntireRow.Hidden = True
            Sheet20.Rows("13:13").EntireRow.Hidden = True
            Sheet21.Rows("13:13").EntireRow.Hidden = True
            Sheet22.Rows("13:13").EntireRow.Hidden = True
            Sheet23.Rows("13:13").EntireRow.Hidden = True
            Sheet24.Rows("13:13").EntireRow.Hidden = True
            Sheet25.Rows("13:13").EntireRow.Hidden = True
            Sheet26.Rows("13:13").EntireRow.Hidden = True
            Sheet27.Rows("13:13").EntireRow.Hidden = True
            Sheet28.Rows("13:13").EntireRow.Hidden = True
            Sheet29.Rows("13:13").EntireRow.Hidden = True
            Sheet30.Rows("13:13").EntireRow.Hidden = True
            Sheet31.Rows("13:13").EntireRow.Hidden = True
            Sheet32.Rows("13:13").EntireRow.Hidden = True
        Else
            Sheet07.Rows("13:13").EntireRow.Hidden = False
            Sheet08.Rows("13:13").EntireRow.Hidden = False
            Sheet09.Rows("13:13").EntireRow.Hidden = False
            Sheet10.Rows("13:13").EntireRow.Hidden = False
            Sheet11.Rows("13:13").EntireRow.Hidden = False
            Sheet12.Rows("13:13").EntireRow.Hidden = False
            Sheet13.Rows("13:13").EntireRow.Hidden = False
            Sheet14.Rows("13:13").EntireRow.Hidden = False
            Sheet15.Rows("13:13").EntireRow.Hidden = False
            Sheet16.Rows("13:13").EntireRow.Hidden = False
            Sheet17.Rows("13:13").EntireRow.Hidden = False
            Sheet18.Rows("13:13").EntireRow.Hidden = False
            Sheet19.Rows("13:13").EntireRow.Hidden = False
            Sheet20.Rows("13:13").EntireRow.Hidden = False
            Sheet21.Rows("13:13").EntireRow.Hidden = False
            Sheet22.Rows("13:13").EntireRow.Hidden = False
            Sheet23.Rows("13:13").EntireRow.Hidden = False
            Sheet24.Rows("13:13").EntireRow.Hidden = False
            Sheet25.Rows("13:13").EntireRow.Hidden = False
            Sheet26.Rows("13:13").EntireRow.Hidden = False
            Sheet27.Rows("13:13").EntireRow.Hidden = False
            Sheet28.Rows("13:13").EntireRow.Hidden = False
            Sheet29.Rows("13:13").EntireRow.Hidden = False
            Sheet30.Rows("13:13").EntireRow.Hidden = False
            Sheet31.Rows("13:13").EntireRow.Hidden = False
            Sheet32.Rows("13:13").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$11" Then
        If Sheet02.Range("J11").Value <= 0 Then
            Sheet07.Rows("14:14").EntireRow.Hidden = True
            Sheet08.Rows("14:14").EntireRow.Hidden = True
            Sheet09.Rows("14:14").EntireRow.Hidden = True
            Sheet10.Rows("14:14").EntireRow.Hidden = True
            Sheet11.Rows("14:14").EntireRow.Hidden = True
            Sheet12.Rows("14:14").EntireRow.Hidden = True
            Sheet13.Rows("14:14").EntireRow.Hidden = True
            Sheet14.Rows("14:14").EntireRow.Hidden = True
            Sheet15.Rows("14:14").EntireRow.Hidden = True
            Sheet16.Rows("14:14").EntireRow.Hidden = True
            Sheet17.Rows("14:14").EntireRow.Hidden = True
            Sheet18.Rows("14:14").EntireRow.Hidden = True
            Sheet19.Rows("14:14").EntireRow.Hidden = True
            Sheet20.Rows("14:14").EntireRow.Hidden = True
            Sheet21.Rows("14:14").EntireRow.Hidden = True
            Sheet22.Rows("14:14").EntireRow.Hidden = True
            Sheet23.Rows("14:14").EntireRow.Hidden = True
            Sheet24.Rows("14:14").EntireRow.Hidden = True
            Sheet25.Rows("14:14").EntireRow.Hidden = True
            Sheet26.Rows("14:14").EntireRow.Hidden = True
            Sheet27.Rows("14:14").EntireRow.Hidden = True
            Sheet28.Rows("14:14").EntireRow.Hidden = True
            Sheet29.Rows("14:14").EntireRow.Hidden = True
            Sheet30.Rows("14:14").EntireRow.Hidden = True
            Sheet31.Rows("14:14").EntireRow.Hidden = True
            Sheet32.Rows("14:14").EntireRow.Hidden = True
        Else
            Sheet07.Rows("14:14").EntireRow.Hidden = False
            Sheet08.Rows("14:14").EntireRow.Hidden = False
            Sheet09.Rows("14:14").EntireRow.Hidden = False
            Sheet10.Rows("14:14").EntireRow.Hidden = False
            Sheet11.Rows("14:14").EntireRow.Hidden = False
            Sheet12.Rows("14:14").EntireRow.Hidden = False
            Sheet13.Rows("14:14").EntireRow.Hidden = False
            Sheet14.Rows("14:14").EntireRow.Hidden = False
            Sheet15.Rows("14:14").EntireRow.Hidden = False
            Sheet16.Rows("14:14").EntireRow.Hidden = False
            Sheet17.Rows("14:14").EntireRow.Hidden = False
            Sheet18.Rows("14:14").EntireRow.Hidden = False
            Sheet19.Rows("14:14").EntireRow.Hidden = False
            Sheet20.Rows("14:14").EntireRow.Hidden = False
            Sheet21.Rows("14:14").EntireRow.Hidden = False
            Sheet22.Rows("14:14").EntireRow.Hidden = False
            Sheet23.Rows("14:14").EntireRow.Hidden = False
            Sheet24.Rows("14:14").EntireRow.Hidden = False
            Sheet25.Rows("14:14").EntireRow.Hidden = False
            Sheet26.Rows("14:14").EntireRow.Hidden = False
            Sheet27.Rows("14:14").EntireRow.Hidden = False
            Sheet28.Rows("14:14").EntireRow.Hidden = False
            Sheet29.Rows("14:14").EntireRow.Hidden = False
            Sheet30.Rows("14:14").EntireRow.Hidden = False
            Sheet31.Rows("14:14").EntireRow.Hidden = False
            Sheet32.Rows("14:14").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$12" Then
        If Sheet02.Range("J12").Value <= 0 Then
            Sheet07.Rows("15:15").EntireRow.Hidden = True
            Sheet08.Rows("15:15").EntireRow.Hidden = True
            Sheet09.Rows("15:15").EntireRow.Hidden = True
            Sheet10.Rows("15:15").EntireRow.Hidden = True
            Sheet11.Rows("15:15").EntireRow.Hidden = True
            Sheet12.Rows("15:15").EntireRow.Hidden = True
            Sheet13.Rows("15:15").EntireRow.Hidden = True
            Sheet14.Rows("15:15").EntireRow.Hidden = True
            Sheet15.Rows("15:15").EntireRow.Hidden = True
            Sheet16.Rows("15:15").EntireRow.Hidden = True
            Sheet17.Rows("15:15").EntireRow.Hidden = True
            Sheet18.Rows("15:15").EntireRow.Hidden = True
            Sheet19.Rows("15:15").EntireRow.Hidden = True
            Sheet20.Rows("15:15").EntireRow.Hidden = True
            Sheet21.Rows("15:15").EntireRow.Hidden = True
            Sheet22.Rows("15:15").EntireRow.Hidden = True
            Sheet23.Rows("15:15").EntireRow.Hidden = True
            Sheet24.Rows("15:15").EntireRow.Hidden = True
            Sheet25.Rows("15:15").EntireRow.Hidden = True
            Sheet26.Rows("15:15").EntireRow.Hidden = True
            Sheet27.Rows("15:15").EntireRow.Hidden = True
            Sheet28.Rows("15:15").EntireRow.Hidden = True
            Sheet29.Rows("15:15").EntireRow.Hidden = True
            Sheet30.Rows("15:15").EntireRow.Hidden = True
            Sheet31.Rows("15:15").EntireRow.Hidden = True
            Sheet32.Rows("15:15").EntireRow.Hidden = True
        Else
            Sheet07.Rows("15:15").EntireRow.Hidden = False
            Sheet08.Rows("15:15").EntireRow.Hidden = False
            Sheet09.Rows("15:15").EntireRow.Hidden = False
            Sheet10.Rows("15:15").EntireRow.Hidden = False
            Sheet11.Rows("15:15").EntireRow.Hidden = False
            Sheet12.Rows("15:15").EntireRow.Hidden = False
            Sheet13.Rows("15:15").EntireRow.Hidden = False
            Sheet14.Rows("15:15").EntireRow.Hidden = False
            Sheet15.Rows("15:15").EntireRow.Hidden = False
            Sheet16.Rows("15:15").EntireRow.Hidden = False
            Sheet17.Rows("15:15").EntireRow.Hidden = False
            Sheet18.Rows("15:15").EntireRow.Hidden = False
            Sheet19.Rows("15:15").EntireRow.Hidden = False
            Sheet20.Rows("15:15").EntireRow.Hidden = False
            Sheet21.Rows("15:15").EntireRow.Hidden = False
            Sheet22.Rows("15:15").EntireRow.Hidden = False
            Sheet23.Rows("15:15").EntireRow.Hidden = False
            Sheet24.Rows("15:15").EntireRow.Hidden = False
            Sheet25.Rows("15:15").EntireRow.Hidden = False
            Sheet26.Rows("15:15").EntireRow.Hidden = False
            Sheet27.Rows("15:15").EntireRow.Hidden = False
            Sheet28.Rows("15:15").EntireRow.Hidden = False
            Sheet29.Rows("15:15").EntireRow.Hidden = False
            Sheet30.Rows("15:15").EntireRow.Hidden = False
            Sheet31.Rows("15:15").EntireRow.Hidden = False
            Sheet32.Rows("15:15").EntireRow.Hidden = False
        End If
    End If
   
    If Target.Address = "$J$13" Then
        If Sheet02.Range("J13").Value <= 0 Then
            Sheet07.Rows("16:16").EntireRow.Hidden = True
            Sheet08.Rows("16:16").EntireRow.Hidden = True
            Sheet09.Rows("16:16").EntireRow.Hidden = True
            Sheet10.Rows("16:16").EntireRow.Hidden = True
            Sheet11.Rows("16:16").EntireRow.Hidden = True
            Sheet12.Rows("16:16").EntireRow.Hidden = True
            Sheet13.Rows("16:16").EntireRow.Hidden = True
            Sheet14.Rows("16:16").EntireRow.Hidden = True
            Sheet15.Rows("16:16").EntireRow.Hidden = True
            Sheet16.Rows("16:16").EntireRow.Hidden = True
            Sheet17.Rows("16:16").EntireRow.Hidden = True
            Sheet18.Rows("16:16").EntireRow.Hidden = True
            Sheet19.Rows("16:16").EntireRow.Hidden = True
            Sheet20.Rows("16:16").EntireRow.Hidden = True
            Sheet21.Rows("16:16").EntireRow.Hidden = True
            Sheet22.Rows("16:16").EntireRow.Hidden = True
            Sheet23.Rows("16:16").EntireRow.Hidden = True
            Sheet24.Rows("16:16").EntireRow.Hidden = True
            Sheet25.Rows("16:16").EntireRow.Hidden = True
            Sheet26.Rows("16:16").EntireRow.Hidden = True
            Sheet27.Rows("16:16").EntireRow.Hidden = True
            Sheet28.Rows("16:16").EntireRow.Hidden = True
            Sheet29.Rows("16:16").EntireRow.Hidden = True
            Sheet30.Rows("16:16").EntireRow.Hidden = True
            Sheet31.Rows("16:16").EntireRow.Hidden = True
            Sheet32.Rows("16:16").EntireRow.Hidden = True
        Else
            Sheet07.Rows("16:16").EntireRow.Hidden = False
            Sheet08.Rows("16:16").EntireRow.Hidden = False
            Sheet09.Rows("16:16").EntireRow.Hidden = False
            Sheet10.Rows("16:16").EntireRow.Hidden = False
            Sheet11.Rows("16:16").EntireRow.Hidden = False
            Sheet12.Rows("16:16").EntireRow.Hidden = False
            Sheet13.Rows("16:16").EntireRow.Hidden = False
            Sheet14.Rows("16:16").EntireRow.Hidden = False
            Sheet15.Rows("16:16").EntireRow.Hidden = False
            Sheet16.Rows("16:16").EntireRow.Hidden = False
            Sheet17.Rows("16:16").EntireRow.Hidden = False
            Sheet18.Rows("16:16").EntireRow.Hidden = False
            Sheet19.Rows("16:16").EntireRow.Hidden = False
            Sheet20.Rows("16:16").EntireRow.Hidden = False
            Sheet21.Rows("16:16").EntireRow.Hidden = False
            Sheet22.Rows("16:16").EntireRow.Hidden = False
            Sheet23.Rows("16:16").EntireRow.Hidden = False
            Sheet24.Rows("16:16").EntireRow.Hidden = False
            Sheet25.Rows("16:16").EntireRow.Hidden = False
            Sheet26.Rows("16:16").EntireRow.Hidden = False
            Sheet27.Rows("16:16").EntireRow.Hidden = False
            Sheet28.Rows("16:16").EntireRow.Hidden = False
            Sheet29.Rows("16:16").EntireRow.Hidden = False
            Sheet30.Rows("16:16").EntireRow.Hidden = False
            Sheet31.Rows("16:16").EntireRow.Hidden = False
            Sheet32.Rows("16:16").EntireRow.Hidden = False
        End If
    End If
End Sub
 
Last edited by a moderator:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I can't figure out how to edit the original post but the sheet name will change. See the screen shot below the (Name) highlighted below will stay the same the the Name in the second screen shot will change as part of another macro on another sheet.

1690956036383.png
1690956087943.png
 
Upvote 0
The sheet name may change, but the sheet code name won't - so provided your sheet names (as described above) coincide with you sheet code names, try the following worksheet code in the sheet code module of the sheet where you make the changes to range "J4:J13". Try it on a copy of your workbook first. If it doesn't work, please share your workbook via Dropbox, Google Drive or similar file sharing platform.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge = 1 And Not Intersect(Range("J4:J13"), Target) Is Nothing Then
        On Error GoTo Escape
        Application.EnableEvents = False
        Application.ScreenUpdating = False
        Dim i As Long, j As Long
        i = Target.Row + 3
        Select Case Target.Value
            Case Is <= 0
                For j = 7 To 32
                    Worksheets(j).Cells(i, 1).EntireRow.Hidden = True
                Next j
            Case Else
                For j = 7 To 32
                    Worksheets(j).Cells(i, 1).EntireRow.Hidden = False
                Next j
        End Select
    End If
Continue:
    Application.ScreenUpdating = True
    Application.EnableEvents = True
    Exit Sub
Escape:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume Continue
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,525
Members
452,651
Latest member
wordsearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top