View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Count With Criteria

You could write a procedure that would loop through the rows and examine the
cells and increment a counter.

Or you could use:

Option Explicit
Sub testme()
Dim myCount As Long
myCount = Worksheets("SheetNameHere") _
.Evaluate("sumproduct(--(a1:a10=""john""),--isnumber(b1:b10))")
MsgBox myCount
End Sub

RMPitcher wrote:

how would I write this in code instead of using it in the worksheet.

IE if I wanted to store the answer in a variable

--
RMPitcher
------------------------------------------------------------------------
RMPitcher's Profile: http://www.thecodecage.com/forumz/member.php?userid=499
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=115086


--

Dave Peterson