View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
JRForm JRForm is offline
external usenet poster
 
Posts: 130
Default CountIF or SumIf Question

jb,

Here is a way to do this in code
Sub jb()

Dim iLastRow As Long
Dim I As Long
Dim J As Long

iLastRow = Range("A" & Range("A:A").Rows.Count).End(xlUp).Row
J = 0
Range("A1").Select

Do Until iLastRow = 0
If ((ActiveCell = "") And (ActiveCell.Offset(0, 1).Value < "") And
(ActiveCell.Offset(0, 1).Value < "")) Then
J = J + 1
End If

iLastRow = iLastRow - 1
ActiveCell.Offset(1, 0).Select
Loop

Range("E1") = J 'where ever you want the total to show

End Sub

"jb" wrote:

Hello,
Following up on previous help provided and which as worked great:

Without having to add a column to a spreadsheet, I need to count the number
of rows that match criteria based on three columns. That is, If column A is
blank AND column B=0 AND column C=0, this would count as 1 valid row,
otherwise 0 valid row. It looks like I could do this somehow with IF() and
I'd like to use one of the functions you guys have been referencing (sumIF,
countIF, etc.). I do not know how to use compound criteria. I thought I
could do something like =Sum(IF(A="" AND B=0 AND C=0, 1, 0)), but that
doesn't
seem to work. I see there is an AND function: AND(A="",B=0,C=0) or
something like
that. I know I could use a DCount() function, but I was hoping to avoid
using
criteria columns in my spreadsheet. Very confused.

Thanks for any help!

John