find所有实例并隐藏行

我有一个可以取值为x0

 x x 0 0 x 0 

我正在寻找一个快速的macros将find所有的x值,并隐藏这些行。 我可以做到这一点通过使用For each cell .. next但我认为必须有一个更快的方式使用数组或东西。

您可以使用SpecialCells()函数来查找文本值。 然后,隐藏这些行。

假设你想检查列A ,这应该做的伎俩:

 Range("A:A").SpecialCells(xlCellTypeConstants, xlTextValues).EntireRow.Hidden = True 

编辑 :Per @ Jeeped的评论如下

如果你使用公式,而你的公式返回0而不是"0" ,那么这应该工作:

 Range("A:A").SpecialCells(xlCellTypeFormulas, xlTextValues).EntireRow.Hidden = True 

以下假定A1中的列标题标签。

 with activesheet if .autofiltermode then .autofiltermode = false with .range(.cells(1,1), .cells(rows.count, 1).end(xlup)) .autofilter field:=1, criteria1:="x", VisibleDropDown:=False end with end with 

这只是一个隐藏小箭头的AutoFilter方法 。 您可以使用常规取消隐藏命令或数据►分类和过滤►清除或简单地closures自动filter来取消隐藏行。