隐藏单元格填充时的行

所以我有单元格A2到E2中的数据(任务)列表,而F列是我的团队为其分配名称的选项。 我试图做的事情,就是在F2,F3,F4 …中input一个名字,相应的行就会消失。

例。

F1 =“鲍勃”,然后行1消失。

这是我迄今为止,但我有一种感觉,我可能会走错了方向。

Option Explicit Private Sub Worksheet_Activate() Dim r As Range, c As Range Set r = Range("a1:a299") Application.ScreenUpdating = False For Each c In r If Len(c.text) = 0 Then c.EntireRow.Hidden = True Else c.EntireRow.Hidden = False End If Next c Application.ScreenUpdating = True End Sub 

我也不确定这是否会马上更新,或者我不得不每次运行macros。 如果我做对了,应该先做。

根据我的评论

 Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) 'check to make sure we only have 1 cell If Target.Count = 1 Then 'check the column If Target.Column = 6 Then 'F column 'check text length and if greater then 0 hide the row If Len(Target.Text) > 0 Then Target.EntireRow.Hidden = True Else Target.EntireRow.Hidden = False End If End If End If End Sub