imback2nite
Board Regular
- Joined
- Oct 30, 2004
- Messages
- 211
- Office Version
- 2003 or older
- Platform
- Windows
I've written this below and it works . . . but it's ugly. I've been trying to learn 'looping' I guess you'd call it but I just don't get it. Is there a better way of writing this?
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
If IsEmpty(Range("B2").Value) = True Then
Rows("3:3").EntireRow.Hidden = False
Rows("4:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B3").Value) = True Then
Rows("4:4").EntireRow.Hidden = False
Rows("5:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B4").Value) = True Then
Rows("5:5").EntireRow.Hidden = False
Rows("6:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B5").Value) = True Then
Rows("6:6").EntireRow.Hidden = False
Rows("7:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B6").Value) = True Then
Rows("7:7").EntireRow.Hidden = False
Rows("8:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B7").Value) = True Then
Rows("8:8").EntireRow.Hidden = False
Rows("9:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B8").Value) = True Then
Rows("9:9").EntireRow.Hidden = False
Rows("10:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B9").Value) = True Then
Rows("10:10").EntireRow.Hidden = False
Rows("11:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B10").Value) = True Then
Rows("11:11").EntireRow.Hidden = False
Rows("12:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B11").Value) = True Then
Rows("12:12").EntireRow.Hidden = False
Rows("13:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B12").Value) = True Then
Rows("13:13").EntireRow.Hidden = False
Rows("14:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B13").Value) = True Then
Rows("14:14").EntireRow.Hidden = False
Rows("15:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B14").Value) = True Then
Rows("15:15").EntireRow.Hidden = False
Rows("16:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B15").Value) = True Then
Rows("16:16").EntireRow.Hidden = False
Rows("17:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B16").Value) = True Then
Rows("17:17").EntireRow.Hidden = False
Rows("18:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B17").Value) = True Then
Rows("18:18").EntireRow.Hidden = False
Rows("19:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B18").Value) = True Then
Rows("19:19").EntireRow.Hidden = False
Rows("20:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B19").Value) = True Then
Rows("20:20").EntireRow.Hidden = False
Rows("21:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B20").Value) = True Then
Rows("21:21").EntireRow.Hidden = False
Rows("22:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B21").Value) = True Then
Rows("22:22").EntireRow.Hidden = False
Rows("23:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B22").Value) = True Then
Rows("23:23").EntireRow.Hidden = False
Rows("24:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B23").Value) = True Then
Rows("24:24").EntireRow.Hidden = False
Rows("25:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B24").Value) = True Then
Rows("25:25").EntireRow.Hidden = False
Rows("26:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B25").Value) = True Then
Rows("26:26").EntireRow.Hidden = False
Rows("27:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B26").Value) = True Then
Rows("27:27").EntireRow.Hidden = False
Rows("28:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B27").Value) = True Then
Rows("28:28").EntireRow.Hidden = False
Rows("29:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B28").Value) = True Then
Rows("29:29").EntireRow.Hidden = False
Rows("30:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B29").Value) = True Then
Rows("30:30").EntireRow.Hidden = False
Rows("31:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B30").Value) = True Then
Rows("31:31").EntireRow.Hidden = False
Rows("32:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B31").Value) = True Then
Rows("32:32").EntireRow.Hidden = False
Rows("33:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B32").Value) = True Then
Rows("33:33").EntireRow.Hidden = False
Rows("34:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B33").Value) = True Then
Rows("34:34").EntireRow.Hidden = False
Rows("35:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B34").Value) = True Then
Rows("35:35").EntireRow.Hidden = False
Rows("36:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B35").Value) = True Then
Rows("36:36").EntireRow.Hidden = False
Rows("37:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B36").Value) = True Then
Rows("37:37").EntireRow.Hidden = False
Rows("38:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B37").Value) = True Then
Rows("38:38").EntireRow.Hidden = False
Rows("39:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B38").Value) = True Then
Rows("39:39").EntireRow.Hidden = False
Rows("40:41").EntireRow.Hidden = True
ElseIf IsEmpty(Range("B39").Value) = True Then
Rows("40:40").EntireRow.Hidden = False
Rows("41:41").EntireRow.Hidden = True
End If
End Sub