自动在Excel中填充两个图表

时间:2019-03-06 16:55:17

标签: excel vba

我正在尝试运行自动显示所请求图表的报告。我能够正确填充此宏。但是,我想在此宏中嵌套第二个条件,以便它将从“ A2”,“ A3”,“ A4”和“ A5”中提取数据。

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Activate
If Not Application.Intersect(Range("A2"), Range(Target.Address)) Is Nothing Then
        Select Case Target.Value
        Case Is = "Tommy": Rows("4:57").EntireRow.Hidden = True
                            Rows("4:13").EntireRow.Hidden = False
                            Rows("37:45").EntireRow.Hidden = False
        Case Is = "Molly":  Rows("4:57").EntireRow.Hidden = True
                            Rows("45:58").EntireRow.Hidden = False
        Case Is = "Joe":  Rows("4:57").EntireRow.Hidden = True
                           Rows("14:18").EntireRow.Hidden = False
        Case Is = "Bill":  Rows("4:57").EntireRow.Hidden = True
                           Rows("19:36").EntireRow.Hidden = False
         End Select
End If
End Sub

0 个答案:

没有答案