View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Counting rows with criteria

Try this

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim num As Long

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

num = 0

With ActiveSheet
For Lrow = Lastrow To Firstrow Step -1

If Application.WorksheetFunction.CountIf(.Rows(Lrow), "x") 0 Then num = num + 1

Next
End With

MsgBox num

End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message ups.com...
Hello,

I've been looking for a solution to this problem, I need to get a count
of all rows that have an "X", but not the total number of "X" in the
range. Any solutions or tips? Thanks!

A B C D
1 / / / /
2 X X X X
3 / / / /
4 / / X /
5 X X X X
6 / X / /
7 X X X X
8 X X X X
9 / / / X
10 / / X X
11 / / / /
12 / / / /
13 / / / /
14 / / / X
15 / / / /
16 X X X X
17 / X / /
18 / / / /
19 / / / /
20 / / X /

TKO