[英]VBA- Hide rows based on whether cell contains specific text
寻找扫描整列以查看产品(在单个单元格中)是否可以停产。 如果单词continuous在单元格中,则为真。 如果要中断整个行,我希望将其隐藏。 有什么建议么?
Sub HideRows()
Dim c As Range
For Each c In Range("B3:B2452")
If InStr(1, c, "Discontinued") Or InStr(1, c, "discontinued") Then
c.EntireRow.Hidden = True
End If
Next
End Sub
Sub HideRows()
Dim rCheck As Range
Dim rHide As Range
Dim rCheckCell As Range
Set rCheck = ActiveWorkbook.ActiveSheet.Range("B3:B2452")
rCheck.EntireRow.Hidden = False
For Each rCheckCell In rCheck.Cells
If InStr(1, rCheckCell, "Discontinued", vbTextCompare) > 0 Then
If Not rHide Is Nothing Then Set rHide = Union(rHide, rCheckCell) Else Set rHide = rCheckCell
End If
Next rCheckCell
If Not rHide Is Nothing Then rHide.EntireRow.Hidden = True
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.