Thread: Count function
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Count function

You dont need to loop...Try the below...

Sub counting()
Dim lngRow As Long
lngRow = Cells(Rows.Count, "U").End(xlUp).Row
Range("U" & lngRow + 1) = "=COUNTIF(U3:U" & lngRow & ",""Equity"")"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"cluckers" wrote:

I am trying to count the number of occurences that the word "equity" appears
in a range. The range is always going to be column U. However, U3 will
always be the first cell in the range but the last cell varies depending on
the data. So I am running a loop to get to the bottom of the range. Once
there I want to run a count command that will count the number of times
"equity" appears in the column.

I am getting an error on my "countif" part that says sub or function not
defined. Not sure if I am even using this correctly. Any ideas?


Sub counting()

Range("U3").Activate

Do Until ActiveCell = ""
ActiveCell.Offset(1, 0).Select

Loop

ActiveCell.Value = CountIf("U3, ActiveCell.Offset(-1, 0)", "Equity")

End Sub


Thanks

Cluckers