The below formula works good for when I put any letter in G13, but what I want to accomplish is to put a specific letter in G13
The Example formula is what I am trying to accomplish with a specific letter to work, letter A to hide rows 119 to 123, B to hide 402 to 415, C to hide rows 119 to 158 and D and M to not hide any rows just hide sheet (model) etc.
I do not know how to make the code to work for each different letter. can it be shorten. Please help!!
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.DisplayAlerts = False
If Target.Address = Range("G13").Address Then
If Target.Value = "" Then
Worksheets("Model").Visible = False
Else
Worksheets("Model").Visible = True
Worksheets("Aircraft").Visible = False
End If
End If
ActiveWorkbook.Saved = True
Application.DisplayAlerts = True
End Sub
Example:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.DisplayAlerts = False
If Target.Address = Range("G13").Address Then
If Target.Value = D or M
Worksheets("MSG").Visible = False
Else
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
If Target.Address = Range("G13").Address = A Then
If Target.Value = A Then
Worksheets("MSG").Visible = False
Worksheets("incoming").Range("119:123").EntireRow.Hidden = True
Else
Worksheets("incoming").Range("119:123").EntireRow.Hidden = False
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
If Target.Address = Range("G13").Address = B Then
If Target.Value = B Then
Worksheets("MSG").Visible = False
Worksheets("incoming").Range("633:706").EntireRow.Hidden = True
Else
Worksheets("incoming").Range("633:706").EntireRow.Hidden = False
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
If Target.Address = Range("G13").Address = C Then
If Target.Value = C Then
Worksheets("MSG").Visible = False
Worksheets("incoming").Range("119:158,633:706").EntireRow.Hidden = True
Else
Worksheets("incoming").Range("119:158,633:706").EntireRow.Hidden = False
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
ActiveWorkbook.Saved = True
Application.DisplayAlerts = True
End Sub
The Example formula is what I am trying to accomplish with a specific letter to work, letter A to hide rows 119 to 123, B to hide 402 to 415, C to hide rows 119 to 158 and D and M to not hide any rows just hide sheet (model) etc.
I do not know how to make the code to work for each different letter. can it be shorten. Please help!!
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.DisplayAlerts = False
If Target.Address = Range("G13").Address Then
If Target.Value = "" Then
Worksheets("Model").Visible = False
Else
Worksheets("Model").Visible = True
Worksheets("Aircraft").Visible = False
End If
End If
ActiveWorkbook.Saved = True
Application.DisplayAlerts = True
End Sub
Example:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.DisplayAlerts = False
If Target.Address = Range("G13").Address Then
If Target.Value = D or M
Worksheets("MSG").Visible = False
Else
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
If Target.Address = Range("G13").Address = A Then
If Target.Value = A Then
Worksheets("MSG").Visible = False
Worksheets("incoming").Range("119:123").EntireRow.Hidden = True
Else
Worksheets("incoming").Range("119:123").EntireRow.Hidden = False
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
If Target.Address = Range("G13").Address = B Then
If Target.Value = B Then
Worksheets("MSG").Visible = False
Worksheets("incoming").Range("633:706").EntireRow.Hidden = True
Else
Worksheets("incoming").Range("633:706").EntireRow.Hidden = False
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
If Target.Address = Range("G13").Address = C Then
If Target.Value = C Then
Worksheets("MSG").Visible = False
Worksheets("incoming").Range("119:158,633:706").EntireRow.Hidden = True
Else
Worksheets("incoming").Range("119:158,633:706").EntireRow.Hidden = False
Worksheets("MSG").Visible = True
Worksheets("Model").Visible = False
End If
End If
ActiveWorkbook.Saved = True
Application.DisplayAlerts = True
End Sub