View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Countif a Name occures in a column

Sub CountNames()
MyName = "Alan"
Set Myrng = Range("A1:A10000")
NameCount = Application.CountIf(Myrng, MyName)
MsgBox NameCount
Range("B1") = Application.CountIf(Myrng, MyName) ' or Range("B1")=NameCount
End Sub


"Tempy" wrote:

Hi all,

I need to count the number of time a name appears in a column and then
save the amount in a cell.

I would like to do this with code as i manipulate the spreadsheet.
I have done it with a countif formular in the cell, nut must one do this
? or is it better to store the total as a variable and then past the
variable into the cell, it is the latter that i am not sure how to do.

Thanks in advance

Tempy

*** Sent via Developersdex http://www.developersdex.com ***