确定给定范围内“查找”的匹配数量

我有一个macrosselect一个特定的范围,然后将find它的数字“0”。 我想知道在我select的范围内出现了多less次“0”,以便我可以创build一个等于该数字的variables。 如何设置一个variables等于查找返回匹配查询的次数?

ActiveCell.Select Selection.Offset(0, 1).Select item = ActiveCell.Value Sheets("Lights").Select Rows(3).Select Selection.Find(What:=item, After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Select q = ActiveCell.row() z = ActiveCell.Column() Range(Cells(q, z), Cells(72, z)).Select Selection.Find(What:="0", After:=ActiveCell, LookIn:=xlValues, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate 

所以如果在范围上有7个实例0,那么我想设置variablesm = 7

 m = WorksheetFunction.CountIf(Selection, 0) 

或部分匹配:

 m = WorksheetFunction.CountIf(Selection, "*0*")