1.右击sheet,选择查看代码,打开vb编辑器

2.在vb编辑器里编写代码:
PrivateSub Worksheet_Change(ByVal Target As Range)
If
Range("B4").Value = "任务事项" Then
Rows("10:10").EntireRow.Hidden =True
Rows("11:11").EntireRow.Hidden =True
Rows("12:12").EntireRow.Hidden =True
Rows("13:13").EntireRow.Hidden =True
Rows("14:14").EntireRow.Hidden =True
Rows("15:15").EntireRow.Hidden =True
Rows("16:16").EntireRow.Hidden =True
Else
Rows("10:10").EntireRow.Hidden =False
Rows("11:11").EntireRow.Hidden =False
Rows("12:12").EntireRow.Hidden =False
Rows("13:13").EntireRow.Hidden =False
Rows("14:14").EntireRow.Hidden =False
Rows("15:15").EntireRow.Hidden =False
Rows("16:16").EntireRow.Hidden =False
End If
End Sub

3.点击右上角关闭按钮,并保存excel为启用宏格式

4.打开.xlsm或者.xltm文件查看功能即可(有时候需要手动启用宏)。

网友评论