创建我VBA对象隐藏和激活如果选择了特定的值基于细胞。这一切都包含在第一列。隐藏细胞基于下拉,保持地激活未被选择时
但是,每当我再继续修改,一旦我输入的信息,它隐藏在我身上的一切任何其他列。
完整的代码如下。这主要是重复5次以上的同样的事情。谢谢!
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Row = 3 And Target.Value = "Cashback" Then
Application.Rows("4:7").Select
Application.Selection.EntireRow.Hidden = False
Else
Application.Rows("4:7").Select
Application.Selection.EntireRow.Hidden = True
End If
If Target.Column = 1 And Target.Row = 3 And Target.Value = "Content" Then
Application.Rows("8:25").Select
Application.Selection.EntireRow.Hidden = False
Else
Application.Rows("8:25").Select
Application.Selection.EntireRow.Hidden = True
End If
If Target.Column = 1 And Target.Row = 3 And Target.Value = "Price Comparison" Then
Application.Rows("26:40").Select
Application.Selection.EntireRow.Hidden = False
Else
Application.Rows("26:40").Select
Application.Selection.EntireRow.Hidden = True
End If
If Target.Column = 1 And Target.Row = 3 And Target.Value = "Technology" Then
Application.Rows("41:52").Select
Application.Selection.EntireRow.Hidden = False
Else
Application.Rows("41:52").Select
Application.Selection.EntireRow.Hidden = True
End If
If Target.Column = 1 And Target.Row = 3 And Target.Value = "Vouchers" Then
Application.Rows("53:79").Select
Application.Selection.EntireRow.Hidden = False
Else
Application.Rows("53:79").Select
Application.Selection.EntireRow.Hidden = True
End If
If Target.Column = 1 And Target.Row = 3 And Target.Value = "All" Then
Application.Rows("3:200").Select
Application.Selection.EntireRow.Hidden = False
End If
End Sub
这清理了我一直在寻找的东西,这是我试图实现的代码更合理的用法。谢谢。 –