excel - Determining the number of matches to a "Find" on a given range -


i have macro selects particular range , find number "0" on it. know how many times "0" appears in range i've selected can create variable equal number. how can set variable equal number of times find returns match query?

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 

so if there 7 instance of 0 on range want set variable m= 7

m = worksheetfunction.countif(selection, 0) 

or partial matches:

m = worksheetfunction.countif(selection, "*0*") 

Comments

Popular posts from this blog

javascript - CasperJS/PhantomJS failing SSL handshakes on some sites even with --ssl-protocol=any -

codeigniter - Fatal error: Call to undefined function lang() in CI Merchant using CardSave -

python - Received unregistered task using Celery with Django -