Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

summarize age groups

  Asked By: Jasmine    Date: Aug 11    Category: MS Office    Views: 662
  

macro to summarize count of persons born before 1960 based on the
following column of birthdates
19631002
19660628
19580908
19571031
19550820

tried =COUNT but didn't get much further

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Dalpat Student     Answered On: Aug 11

Loop through range with
if Entry < 19600000 then counter = counter +1

provided that Entry is Long, not Int

 
Answer #2    Answered By: Priscilla Lewis     Answered On: Aug 11

Try this

Sub CountBirthday()
i = 1
Count = 0
With ActiveSheet
Do While .Cells(i, 1) <> "" 'assuming datas are on column 1 (A)
If Left(.Cells(i, 1), 4) < 1960 Then 'count the number of
person born before 1960
Count = count  + 1
End If
i = i + 1
Loop
.Cells(i, 1) = Count 'display result on last row of column A
End With
End Sub

 
Answer #3    Answered By: Delbert Cooper     Answered On: Aug 11

You don't really need vba for this; assuming the column of figures
below is in cells E23:E27 then
=COUNTIF(E23:E27,"<19600000")
in any other cell should work

 
Didn't find what you were looking for? Find more on summarize age groups Or get search suggestion and latest updates.




Tagged: