Merry Christmas to all!
Is there a way to improve this code?
Thank you in advance for help /bow/
Is there a way to improve this code?
Code:
[B]Private Sub Worksheet_Change(ByVal Target As Range)[/B]
[B]Dim MyCells As Range[/B]
[B]Set MyCells = Range("B8:B16")[/B]
[B]If Not Intersect(Target, MyCells) Is Nothing Then[/B]
[B]Application.EnableEvents = False[/B]
[B]Application.ScreenUpdating = False[/B]
[B]Application.Calculation = xlCalculationManual[/B]
[B]Sheets(1).Range("7:26").EntireRow.Hidden = False[/B]
[B]Sheets(2).Range("7:36").EntireRow.Hidden = False[/B]
[B]If Range("B7").Value = "" Then[/B]
[B]Sheets(1).Range("7:8").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("7:9").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B8").Value = "" Then[/B]
[B]Sheets(1).Range("9:10").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("10:12").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B9").Value = "" Then[/B]
[B]Sheets(1).Range("11:12").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("13:15").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B10").Value = "" Then[/B]
[B]Sheets(1).Range("13:14").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("16:18").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B11").Value = "" Then[/B]
[B]Sheets(1).Range("15:16").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("19:21").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B12").Value = "" Then[/B]
[B]Sheets(1).Range("17:18").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("22:24").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B13").Value = "" Then[/B]
[B]Sheets(1).Range("19:20").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("25:27").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B14").Value = "" Then[/B]
[B]Sheets(1).Range("21:22").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("28:30").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B15").Value = "" Then[/B]
[B]Sheets(1).Range("23:24").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("31:33").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]If Range("B16").Value = "" Then[/B]
[B]Sheets(1).Range("25:26").EntireRow.Hidden = True[/B]
[B]Sheets(2).Range("34:36").EntireRow.Hidden = True[/B]
[B]End If[/B]
[B]Application.EnableEvents = True[/B]
[B]Application.ScreenUpdating = True[/B]
[B]Application.Calculation = xlCalculationAutomatic[/B]
[B]End If[/B]
[B]End Sub[/B]
Thank you in advance for help /bow/
Last edited: