简体   繁体   English

如果单元格包含某个字符串值,则在Excel中隐藏行

[英]Hide rows in Excel if a cell contains a certain string value

I want to hide the entire rows 8 to 32 in my worksheet if cell K22 contains "true" and if not I want them to be shown. 如果单元格K22包含“ true”,我想在工作表中隐藏整行8至32,否则,我希望它们显示出来。

If anyone could help that would be great! 如果有人可以帮助,那就太好了!

Heres what I've tried. 这是我尝试过的。

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Range("K22").Value = "True" Then
    Rows("8:32").EntireRow.Hidden = False
Else
    Rows("8:32").EntireRow.Hidden = True
End If

End Sub

try 尝试

Private Sub Worksheet_Change(ByVal Target As Range)
    Rows("8:32").EntireRow.Hidden = IIf(UCase(Range("K22")) = "TRUE", True, False)
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM