Thread: Count function
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
FSt1 FSt1 is offline
external usenet poster
 
Posts: 3,942
Default Count function

hi
if all you are trying to do is put the value of the count in last cell,
this might be a better way
Sub countit()
Dim c As Long
c = 0
Range("U3").Activate
Do Until ActiveCell = ""
ActiveCell.Offset(1, 0).Select
If ActiveCell.Value = "Equity" Then
c = c + 1
End If
Loop
ActiveCell.Value = c
end sub

regards
FSt1

"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