PDA

View Full Version : how to count rows with specific data in A:A



jimnewton
02-20-2008, 10:36 AM
I'm sure this must be simple but i can't get it to work!
i need to count the rows with specifiic data in column A to a variable within the macro.
currently been trying to use

Sub countrow()


n = 4
A = 0
Do
If Cells(n, 1) = "Pipes" Then A = A + 1
n = n + 1
Loop Until Cells(n, 1) = "trees"

mdmackillop
02-20-2008, 10:50 AM
Option Compare Text
Sub CountStuff()
Dim n As Long
n = Application.CountIf(Range("A:A"), "pipes")
MsgBox n
End Sub