Hello-
I am trying to use a simple macro to hide rows based on the value of three different cells. The code tat I am currently using is below. The first portion works correctly, however when I copy it to use on the other required rows it doesn't work. Can someone please assist? I'm new to VBA. Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("b23").Value = "FS" Then
Rows("25:25").EntireRow.Hidden = True
ElseIf Range("B23").Value = "NNN" Then
Rows("25:25").EntireRow.Hidden = True
ElseIf Range("B23").Value = "IG" Then
Rows("25:25").EntireRow.Hidden = False
ElseIf Range("B23").Value = "Net of Electric" Then
Rows("25:25").EntireRow.Hidden = False
End If
End Sub
Private Sub Worksheet_Change2(ByVal Target As Range)
If Range("B11").Value = "FS" Then
Rows("13:13").EntireRow.Hidden = True
ElseIf Range("B11").Value = "NNN" Then
Rows("13:13").EntireRow.Hidden = True
ElseIf Range("B11").Value = "IG" Then
Rows("13:13").EntireRow.Hidden = False
ElseIf Range("B11").Value = "Net of Electric" Then
Rows("13:13").EntireRow.Hidden = False
End If
End Sub
Private Sub Worksheet_Change3(ByVal Target As Range)
If Range("B35").Value = "FS" Then
Rows("37:37").EntireRow.Hidden = True
ElseIf Range("B35").Value = "NNN" Then
Rows("37:37").EntireRow.Hidden = True
ElseIf Range("B35").Value = "IG" Then
Rows("37:37").EntireRow.Hidden = False
ElseIf Range("B35").Value = "Net of Electric" Then
Rows("37:37").EntireRow.Hidden = False
End If
End Sub
I am trying to use a simple macro to hide rows based on the value of three different cells. The code tat I am currently using is below. The first portion works correctly, however when I copy it to use on the other required rows it doesn't work. Can someone please assist? I'm new to VBA. Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("b23").Value = "FS" Then
Rows("25:25").EntireRow.Hidden = True
ElseIf Range("B23").Value = "NNN" Then
Rows("25:25").EntireRow.Hidden = True
ElseIf Range("B23").Value = "IG" Then
Rows("25:25").EntireRow.Hidden = False
ElseIf Range("B23").Value = "Net of Electric" Then
Rows("25:25").EntireRow.Hidden = False
End If
End Sub
Private Sub Worksheet_Change2(ByVal Target As Range)
If Range("B11").Value = "FS" Then
Rows("13:13").EntireRow.Hidden = True
ElseIf Range("B11").Value = "NNN" Then
Rows("13:13").EntireRow.Hidden = True
ElseIf Range("B11").Value = "IG" Then
Rows("13:13").EntireRow.Hidden = False
ElseIf Range("B11").Value = "Net of Electric" Then
Rows("13:13").EntireRow.Hidden = False
End If
End Sub
Private Sub Worksheet_Change3(ByVal Target As Range)
If Range("B35").Value = "FS" Then
Rows("37:37").EntireRow.Hidden = True
ElseIf Range("B35").Value = "NNN" Then
Rows("37:37").EntireRow.Hidden = True
ElseIf Range("B35").Value = "IG" Then
Rows("37:37").EntireRow.Hidden = False
ElseIf Range("B35").Value = "Net of Electric" Then
Rows("37:37").EntireRow.Hidden = False
End If
End Sub