View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
whitehurst[_2_] whitehurst[_2_] is offline
external usenet poster
 
Posts: 1
Default COUNTIF criteria in VBA


What vba function can I use that checks criteria much like SUMIF o
COUNTIF uses? In other words, say you want to write COUNTIF that onl
includes visible cells...

Public Function CountVIf(rng As range, criteria As String)
Dim cell As range, cmd As String

For Each cell In rng
If cell.RowHeight < 0 And cell.ColumnWidth < 0 Then
cmd = "COUNTIF(" & cell.Address & ",""" & criteria & """)"
CountVIf = CountVIf + Evaluate(cmd)
End If
Next cell
End Function

How can I do this without having to rely on Evaluate("COUNTIF...."?

Thanks

--
whitehurs
-----------------------------------------------------------------------
whitehurst's Profile: http://www.excelforum.com/member.php...fo&userid=3454
View this thread: http://www.excelforum.com/showthread.php?threadid=55035