Countif a Name occures in a column

T

Tempy

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
 
M

Mike Fogleman

Sub CountName ()
Dim numname as Long
Dim namerng as Range

Set namerng as Sheets("Sheet1").Range("A1:A100") 'where your list of
names are located
numname = Application.WorksheetFunction.Countif("Name", namerng)
Sheets("Sheet1").Range("B1"). Value = numname 'puts answer on sheet
End Sub

Mike F
 
G

Guest

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
 
J

Jim May

Sub Foo()
cnum = Application.CountIf(Range("C:C"), "*" & Test & "*")
Range("A1").Value = cnum
End Sub
 
T

Tempy

Could you please give me some more advice on this topic.

I need to look for 19 different names and put the totals in a column. Is
it possible to have a list of names, perhaps in my Personal.xls
workbook, and with the code find the results for one name, paste it and
then get the next name, until the end of the list ?


Tempy
 
D

Don Guillett

Name your list of names and do a loop or just use a vlookup formula

for each name in [mylistofnames]
code
next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top